Class Swift9xxBase
Generic base class for SWIFT MT-940 and SWIFT MT-942 Cash Management messages.
public class Swift9xxBase : IEnumerable, IComparable
- Inheritance
-
Swift9xxBase
- Implements
- Derived
- Inherited Members
Remarks
This base class implements the common properties and utility methods that are applicable to most SWIFT MT-9xx Cash Management messages. It can be used to read most information from a MT-940 or MT-942 message without knowing the message type. After successfully reading a message with ReadMessage(SwiftStatementReader), the property MT is set to indicate the message type that was actually read.
The following derived classes are included in the Subsembly.Swift namespace: SwiftStatement for MT-940 messages and SwiftInterimTransRept for MT-942 messages. Specialisations for MT-920, MT-941, and MT-950 may be added in future versions.
Properties
Account
public SwiftAcct Account { get; }
Property Value
AccountBIC
The account BIC extracted from the AccountIdentification.
public string AccountBIC { get; }
Property Value
AccountBankCode
The account bank code extracted from the AccountIdentification.
public string AccountBankCode { get; }
Property Value
AccountCurrency
The account currency code extracted from the AccountIdentification.
public string AccountCurrency { get; }
Property Value
AccountIBAN
The account IBAN extracted from the AccountIdentification.
public string AccountIBAN { get; }
Property Value
AccountIdentification
Account identification for this message.
public string AccountIdentification { get; set; }
Property Value
- string
The AccountIdentification property corresponds with field 25 of a SWIFT MT-9xx message. This field must not be longer than 35 characters.
Remarks
SWIFT does not define any specific structure or content of this field. However there are several national and proprietary guidelines on how to use this field.
- See Also
AccountNumber
The account number extracted from the AccountIdentification.
public string AccountNumber { get; }
Property Value
Count
Provides the number of StatementLines.
public int Count { get; }
Property Value
CreationDate
protected virtual DateTime CreationDate { get; }
Property Value
MT
The actual MT message type that was read by ReadMessage(SwiftStatementReader).
public int MT { get; }
Property Value
- int
This is initially zero and is updated to 940 or 942 depending on the message type that was read by ReadMessage(SwiftStatementReader).
RelatedReference
The transaction reference that this message relates to.
public string RelatedReference { get; set; }
Property Value
- string
The related reference corresponds with field 21 of a SWIFT MT-9xx message. This field must not start or end with a slash ’/’ and must not contain two consecutive slashes ’//’. It must not be longer than 16 characters.
Remarks
If a MT-9xx message was solicited through another SWIFT message such as MT-920, then the related reference field of the response SWIFT message should contain the transaction reference of the requesting message. If a MT-9xx message was requested through other means or is an unsolicited message, then the related reference is not used and should be omitted.
SequenceNumber
The sequence number of the message in a multi-message statement.
public int SequenceNumber { get; set; }
Property Value
- int
The SequenceNumber property corresponds with the second subfield of field 28 or 28C of a SWIFT MT-9xx message. This subfield contains up to five digits (two digits for field 28) that represent the sequence number. If a sequence number is not applicable, then the value zero is used instead.
Remarks
The Sequence Number subfield is optional. Therefore it will only appear in generated messages, if it is non-zero.
StatementLines
Collection of SwiftStatementLine instances that contain the statement lines this message.
public IList StatementLines { get; }
Property Value
- IList
The collection is initially all empty. It is populated by reading a MT-9xx message or by manually adding statement lines to this message. The collection is always maintained sorted by the EntryDate of the statement lines.
The caller may only read the returned collection any must not change it or change any of the SwiftStatementLine instances that it contains. Any changes to the statement must be done through properties and/or methods of this or the derived instances.
StatementNumber
Statement number of this message.
public int StatementNumber { get; set; }
Property Value
- int
The StatementNumber property corresponds with the first subfield of field 28 or 28C of a SWIFT MT-9xx message. This subfield contains up to five digits that represent the statement number. If a statement number is not applicable, then the value zero is used instead.
TransactionReference
Transaction reference assigned by the sender to unambiguously identify the message.
public string TransactionReference { get; set; }
Property Value
- string
The transaction reference corresponds with field 20 of a SWIFT MT-9xx message. This field must not start or end with a slash ’/’ and must not contain two consecutive slashes ’//’. It must not be longer than 16 characters.
Methods
AddStatementLine(SwiftStatementLine)
public virtual void AddStatementLine(SwiftStatementLine aStatementLine)
Parameters
aStatementLine
SwiftStatementLine
CompareTo(object)
public int CompareTo(object aObject)
Parameters
aObject
object
Returns
GetEnumerator()
public IEnumerator GetEnumerator()
Returns
GetStatementLine(int)
Direct access to individual statement lines.
public SwiftStatementLine GetStatementLine(int i)
Parameters
i
intThe index position of the statement line to retrieve.
Returns
- SwiftStatementLine
The statement line at the requested position.
Exceptions
- ArgumentOutOfRangeException
The given index position was outside of the range of the available statement lines.
Insert(SwiftStatementLine)
Insert a new statement line into this statement lines collection.
public int Insert(SwiftStatementLine aStatementLine)
Parameters
aStatementLine
SwiftStatementLineThe new statement line that shall be inserted. The statement line It will be inserted according to it's entry date in order to ensure that the collection is always maintained in a sorted order. If there are already entries with the same entry date in this collection, then the new statement line will always be added behind as the very last entry with that entry date. If the given statement line does not have an entry date, then it is added to the very end of the collection.
Returns
- int
Returns the index position at which the new statement line was inserted.
Exceptions
- ArgumentNullException
The parameter aStatementLine was
null
.
ParseField(SwiftStatementReaderState, SwiftField)
Callback that is invoked by ReadMessage(SwiftStatementReader) for any fields that are unknown to this Swift9xxBase class.
protected virtual void ParseField(SwiftStatementReaderState nState, SwiftField aField)
Parameters
nState
SwiftStatementReaderStateThe state that the SwiftStatementReader is in, after the provided field has been read.
aField
SwiftFieldThe SwiftField that is unknown to this Swift9xxBase class which shall be processed by the derived class.
ReadAllMessages(SwiftStatementReader, int)
Reads all SWIFT MT-9xx messages from the given SwiftStatementReader, creating a new Swift9xxBase instance for every message read.
public static Swift9xxBase[] ReadAllMessages(SwiftStatementReader aStatementReader, int nMT)
Parameters
aStatementReader
SwiftStatementReadernMT
intThe expected Message Type of all SWIFT messages contained in the source. This must be either 940, or 942, or 999. If this is 940 or 999, then instances of SwiftStatement will be created for reading the messages. If this is 942, then SwiftInterimTransRept instances will be created for reading the messages.
Returns
- Swift9xxBase[]
An array of Swift9xxBase derived instances that contain all the MT-940 or MT-942 messages that have been read. If the given SwiftStatementReader was already at the end of the data when this method was called, then an empty array is returned.
Exceptions
- ArgumentNullException
The parameter
aStatementReader
was null.- ArgumentException
An unknown message type was set in
nMT
.
ReadAllMessages(Stream, int)
Reads all SWIFT MT-9xx messages from the given stream, creating a new Swift9xxBase instance for every message read.
public static Swift9xxBase[] ReadAllMessages(Stream aStream, int nMT)
Parameters
aStream
StreamAn input stream from which the statement data shall be read. This stream will not be closed by this method.
nMT
intThe expected Message Type of all SWIFT messages contained in the source. This must be either 940, or 942, or 999. If this is 940 or 999, then instances of SwiftStatement will be created for reading the messages. If this is 942, then SwiftInterimTransRept instances will be created for reading the messages.
Returns
- Swift9xxBase[]
An array of Swift9xxBase derived instances that contain all the MT-940 or MT-942 messages that have been read. If the given
aStream
was already at the end of the data when this method was called, then an empty array is returned.
Exceptions
- ArgumentNullException
The parameter
aStream
was null.- ArgumentException
An unknown message type was set in
nMT
.
ReadAllMessages(TextReader, int)
Reads all SWIFT MT-9xx messages from the given stream, creating a new Swift9xxBase instance for every message read.
public static Swift9xxBase[] ReadAllMessages(TextReader aTextReader, int nMT)
Parameters
aTextReader
TextReadernMT
intThe expected Message Type of all SWIFT messages contained in the source. This must be either 940, or 942, or 999. If this is 940 or 999, then instances of SwiftStatement will be created for reading the messages. If this is 942, then SwiftInterimTransRept instances will be created for reading the messages.
Returns
- Swift9xxBase[]
An array of Swift9xxBase derived instances that contain all the MT-940 or MT-942 messages that have been read. If the given
aTextReader
was already at the end of the data when this method was called, then an empty array is returned.
Exceptions
- ArgumentNullException
The parameter
aTextReader
was null.- ArgumentException
An unknown message type was set in
nMT
.
ReadAllMessages(string, int)
Reads all SWIFT MT-9xx messages from the given file, creating new Swift9xxBase derived instances for every message read.
public static Swift9xxBase[] ReadAllMessages(string sFilename, int nMT)
Parameters
sFilename
stringnMT
intThe expected Message Type of all SWIFT messages contained in the source. This must be either 940, or 942, or 999. If this is 940 or 999, then instances of SwiftStatement will be created for reading the messages. If this is 942, then SwiftInterimTransRept instances will be created for reading the messages.
Returns
- Swift9xxBase[]
An array of Swift9xxBase derived instances that contain all the MT-940 or MT-942 messages that have been read.
Exceptions
- ArgumentNullException
The parameter
sFilename
was null.- ArgumentException
An unknown message type was set in
nMT
.
ReadMessage(SwiftStatementReader)
Reads a single MT-9xx message terminated by EndOfText or EndOfStream.
public bool ReadMessage(SwiftStatementReader aStatementReader)
Parameters
aStatementReader
SwiftStatementReaderA SwiftStatementReader instance that provides the SWIFT MT-9xx message to be read.
Returns
- bool
If a message was read, then
true
is returned. If the provided input was completely empty, thenfalse
is returned.
Remarks
This method will read and parse all fields that are known by this Swift9xxBase class and update the properties according to the field data that was read. Also, all statement lines that appear in the input are automatically added to the StatementLines collection of this class. All remaining, unknown fields are forwarded to the abstract method ParseField(SwiftStatementReaderState, SwiftField) for reading.
WriteProlog(SwiftWriter)
Writes the common MT-9xx prolog fields.
protected void WriteProlog(SwiftWriter aSwiftWriter)
Parameters
aSwiftWriter
SwiftWriterDestination to write the SWIFT MT-9xx prolog fields to.
Remarks
the common prolog consists of the fields 20, 21, 25, and 28C.
WriteStatementLines(SwiftWriter)
Writes all contained Statement Lines as a sequence of SWIFT fields 61 and 86.
protected void WriteStatementLines(SwiftWriter aSwiftWriter)
Parameters
aSwiftWriter
SwiftWriterDestination to write the SWIFT Statement Lines to.