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
documentXDocumentThe XDocument to wrap. Cannot be null.
rootNamestringThe name of the root element.
Exceptions
- ArgumentNullException
Thrown if
documentis null.
Fields
_defaultNamespace
Represents the default XML namespace used by the containing class or its derived types.
protected readonly XNamespace _defaultNamespace
Field Value
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
_root
Represents the root XML element associated with the current instance.
protected readonly XElement _root
Field Value
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
streamStreamThe stream to which the document will be written. The stream must be writable and remain open for the duration of the operation.
optionsSaveOptionsThe 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
fileNamestringThe path and name of the file to which the document will be saved. Cannot be null or empty.
optionsSaveOptionsThe 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
streamStreamThe stream to which the document will be saved. Must be writable and remain open for the duration of the operation.
optionsSaveOptionsOptions that control how the document is saved. The default is None.
cancellationTokenCancellationTokenA cancellation token that can be used to cancel the save operation.
Returns
- Task
A task that represents the asynchronous save operation.