Table of Contents

Class XmlDocumentBase

Namespace
Tudormobile.Strava.Documents
Assembly
Tudormobile.Strava.dll

Provides a base class for XML document wrappers, offering common save operations for derived XML document types.

public abstract class XmlDocumentBase
Inheritance
XmlDocumentBase
Derived
Inherited Members

Constructors

XmlDocumentBase(XDocument, string)

Initializes a new instance of the XmlDocumentBase class with the specified XDocument.

protected XmlDocumentBase(XDocument document, string rootName)

Parameters

document XDocument

The XDocument to wrap. Cannot be null.

rootName string

The name of the root element.

Exceptions

ArgumentNullException

Thrown if document is null.

Fields

_defaultNamespace

Represents the default XML namespace used by the containing class or its derived types.

protected readonly XNamespace _defaultNamespace

Field Value

XNamespace

Remarks

This field is intended for use by derived classes to provide a consistent namespace context for XML operations. The value should be assigned during construction and remain unchanged throughout the lifetime of the object.

_document

The underlying XDocument instance representing the XML document.

protected readonly XDocument _document

Field Value

XDocument

_root

Represents the root XML element associated with the current instance.

protected readonly XElement _root

Field Value

XElement

Remarks

This field provides direct access to the underlying root XElement for derived classes. It is intended for use within subclasses that require manipulation or inspection of the XML structure.

Methods

Save(Stream, SaveOptions)

Saves the current document to the specified stream using the provided save options.

public void Save(Stream stream, SaveOptions options = SaveOptions.None)

Parameters

stream Stream

The stream to which the document will be written. The stream must be writable and remain open for the duration of the operation.

options SaveOptions

The options that control how the document is saved. If not specified, None is used.

Save(string, SaveOptions)

Saves the current document to the specified file using the provided save options.

public void Save(string fileName, SaveOptions options = SaveOptions.None)

Parameters

fileName string

The path and name of the file to which the document will be saved. Cannot be null or empty.

options SaveOptions

The options that control how the document is saved. If not specified, None is used.

SaveAsync(Stream, SaveOptions, CancellationToken)

Asynchronously saves the document to the specified stream using the provided save options.

public Task SaveAsync(Stream stream, SaveOptions options = SaveOptions.None, CancellationToken cancellationToken = default)

Parameters

stream Stream

The stream to which the document will be saved. Must be writable and remain open for the duration of the operation.

options SaveOptions

Options that control how the document is saved. The default is None.

cancellationToken CancellationToken

A cancellation token that can be used to cancel the save operation.

Returns

Task

A task that represents the asynchronous save operation.