-
Notifications
You must be signed in to change notification settings - Fork 5
/
IdentificationLineParser.cs
36 lines (34 loc) · 1.33 KB
/
IdentificationLineParser.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using CodaParser.Lines;
using CodaParser.Values;
namespace CodaParser.LineParsers
{
/// <summary>
/// The parser for the header record of the transaction.
/// </summary>
public class IdentificationLineParser : ILineParser
{
/// <inheritdoc />
public bool CanAcceptString(string codaLine)
{
return codaLine.Length == 128 && codaLine.Substring(0, 1) == "0";
}
/// <inheritdoc />
public ILine Parse(string codaLine)
{
return new IdentificationLine(
new Date(codaLine.Substring(5, 6)),
new BankIdentificationNumber(codaLine.Substring(11, 3)),
codaLine.Substring(16, 1) == "D" ? true : false,
new ApplicationCode(codaLine.Substring(14, 2)),
new FileReference(codaLine.Substring(24, 10)),
new AccountName(codaLine.Substring(34, 26)),
new Bic(codaLine.Substring(60, 11)),
new CompanyIdentificationNumber(codaLine.Substring(71, 11)),
new ExternalApplicationCode(codaLine.Substring(83, 5)),
new TransactionReference(codaLine.Substring(88, 16)),
new RelatedReference(codaLine.Substring(104, 16)),
new VersionCode(codaLine.Substring(127, 1))
);
}
}
}