Class SepaObject
Abstract base class of all SEPA objects that can be read and written in XML format.
public abstract class SepaObject
- Inheritance
-
SepaObject
- Derived
- Inherited Members
Constructors
SepaObject(string, bool)
public SepaObject(string sTagName, bool fIsMandatory)
Parameters
sTagNamestringThe local name of the XML element tag that represents this object.
fIsMandatoryboolIf the XML element represented by this object is mandatory within its XML parent element, then this must be
true. If it is optional, then this must befalse.
Exceptions
- ArgumentNullException
The parameter
sTagNamewasnull.- ArgumentException
The parameter
sTagNamewas not a valid tag name.
Properties
IsEmpty
Checks whether this object, and all its child objects, are completely empty, such that it won't write anything.
public abstract bool IsEmpty { get; }
Property Value
IsMandatory
Indicates whether the XML element represented by this object is mandatory within its XML parent element
public bool IsMandatory { get; }
Property Value
IsValid
Indicates whether all properties of this SEPA object and all child SEPA objects are correctly set up.
public bool IsValid { get; }
Property Value
- See Also
TagName
The local name of the XML tag that represents this object.
public string TagName { get; }
Property Value
Methods
Clear()
Clear the current content and the content of all childs of this SEPA object.
public abstract void Clear()
OnAfterXmlRead(SepaMessageInfo)
Called after an xml object has been completely read. This is the perfect location to do some additional logical checks.
protected virtual void OnAfterXmlRead(SepaMessageInfo aMessageInfo)
Parameters
aMessageInfoSepaMessageInfo
OnReadObjectXml(XmlReader, SepaMessageInfo, string)
May be overridden instead of OnReadXml(XmlReader, SepaMessageInfo) in order to take over
complete control over how this object is read from the
aXmlReader.
protected virtual bool OnReadObjectXml(XmlReader aXmlReader, SepaMessageInfo aMessageInfo, string sTagName)
Parameters
aXmlReaderXmlReaderaMessageInfoSepaMessageInfosTagNamestringThe object shall be read using this XML tag, instead of TagName.
Returns
- bool
If the object was successfully read from the
aXmlReader, thentrueis returned. If the next XML element is not an XML element representing this object, thenfalseis returned, and the XML reader stays at the current reading position.
Remarks
If this is overridden, then OnWriteObjectXml(XmlWriter, SepaMessageInfo, string) must be overridden, too. In addition, OnWriteXml(XmlWriter, SepaMessageInfo) and OnReadXml(XmlReader, SepaMessageInfo) must be overridden with an usually empty implementation.
The default implementation tries to read the opening sTagName,
then, if such tag was read, calls OnReadXml(XmlReader, SepaMessageInfo) and finally reads the
closing tag.
OnReadXml(XmlReader, SepaMessageInfo)
Must be overridden in order to read the content and childs of this SEPA object.
protected abstract void OnReadXml(XmlReader aXmlReader, SepaMessageInfo aMessageInfo)
Parameters
aXmlReaderXmlReaderaMessageInfoSepaMessageInfo
Remarks
Before this method is called, the method Clear() was called. Only if the appropriate XML element tag was read, then this method is invoked to read the content of the element. The implementation shall not read the ending element tag. This is not invoked for empty elements.
OnValidate(ICollection<SepaException>, string)
Override this in order to validate this SEPA object and all its child objects.
protected abstract void OnValidate(ICollection<SepaException> vErrors, string sPath)
Parameters
vErrorsICollection<SepaException>Container that receives all diagnostic output from validation. For each error found, an implementation shall create a SepaException and add it to this container.
sPathstringThe complete path from the SEPA document root to this object, including the TagName of this object as the last part of the path. This path shall be used for any SepaException objects added to the
vErrorscollection.
Remarks
This is called from Validate(ICollection<SepaException>, string) only, if this object is not IsEmpty.
OnWriteObjectXml(XmlWriter, SepaMessageInfo, string)
May be overridden instead of OnWriteXml(XmlWriter, SepaMessageInfo) in order to take over
complete control over how this object is written to the
aXmlWriter.
protected virtual void OnWriteObjectXml(XmlWriter aXmlWriter, SepaMessageInfo aMessageInfo, string sTagName)
Parameters
aXmlWriterXmlWriteraMessageInfoSepaMessageInfosTagNamestringThe object shall be written using this XML tag, instead of TagName.
Remarks
If this is overridden, then OnReadObjectXml(XmlReader, SepaMessageInfo, string) must be overridden, too. In addition, OnWriteXml(XmlWriter, SepaMessageInfo) and OnReadXml(XmlReader, SepaMessageInfo) must be overridden with an usually empty implementation.
The default implementation writes the opening sTagName, calls
OnWriteXml(XmlWriter, SepaMessageInfo) and then writes the closing tag.
OnWriteXml(XmlWriter, SepaMessageInfo)
Must be overrieden in order to write the content and childs of this SEPA object.
protected abstract void OnWriteXml(XmlWriter aXmlWriter, SepaMessageInfo aMessageInfo)
Parameters
aXmlWriterXmlWriteraMessageInfoSepaMessageInfo
Remarks
This is only called, when this object is IsMandatory or is not IsEmpty.
ReadXml(XmlReader, SepaMessageInfo)
Reads this SEPA object, if it is present.
public void ReadXml(XmlReader aXmlReader, SepaMessageInfo aMessageInfo)
Parameters
aXmlReaderXmlReaderaMessageInfoSepaMessageInfo
Remarks
If the XML reader is not at a TagName starting tag, then nothing will be read. Still, Clear() and OnAfterXmlRead(SepaMessageInfo) will be called.
ReadXml(XmlReader, SepaMessageInfo, string)
Reads this SEPA object, if it is present.
public void ReadXml(XmlReader aXmlReader, SepaMessageInfo aMessageInfo, string sTagName)
Parameters
aXmlReaderXmlReaderaMessageInfoSepaMessageInfosTagNamestringXML tag name that is expected for the object. This overrides the TagName, which would otherwise be expected.
Remarks
If the XML reader is not at a sTagName starting tag, then
nothing will be read. Still, Clear() and OnAfterXmlRead(SepaMessageInfo)
will be called.
Validate(ICollection<SepaException>, string)
Validate this SEPA object and all its child objects without throwing an exception.
public void Validate(ICollection<SepaException> vErrors, string sPath)
Parameters
vErrorsICollection<SepaException>Container that receives all diagnostic output from validation. For each error found, a SepaException is created and added to this container.
sPathstringThe complete path from the SEPA document root to this object, including the TagName of this object as the last part of the path. This path shall be used for any SepaException objects added to the
vErrorscollection.
Exceptions
- ArgumentNullException
The parameter
vErrors, orsPathwasnull.
WriteXml(XmlWriter, SepaMessageInfo)
public void WriteXml(XmlWriter aXmlWriter, SepaMessageInfo aMessageInfo)
Parameters
aXmlWriterXmlWriteraMessageInfoSepaMessageInfo
Remarks
This will only write this element when it is mandatory OR it is not empty.
WriteXml(XmlWriter, SepaMessageInfo, string)
public void WriteXml(XmlWriter aXmlWriter, SepaMessageInfo aMessageInfo, string sTagName)
Parameters
aXmlWriterXmlWriteraMessageInfoSepaMessageInfosTagNamestring