-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRecordTypes.cs
44 lines (40 loc) · 1.49 KB
/
RecordTypes.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
37
38
39
40
41
42
43
44
using System;
using System.Collections.Generic;
using System.Linq;
using CompAnalytics.X9.Records;
namespace CompAnalytics.X9
{
internal static class RecordTypes
{
static readonly Dictionary<Type, string> Lut = new Dictionary<Type, string>
{
{ typeof(FileHeaderRecord), "01" },
{ typeof(CashLetterHeaderRecord), "10" },
{ typeof(BundleHeaderRecord), "20" },
{ typeof(CheckDetailRecord), "25" },
{ typeof(CheckDetailAddendumARecord), "26" },
{ typeof(ReturnRecord), "31" },
{ typeof(ReturnAddendumARecord), "32" },
{ typeof(ReturnAddendumBRecord), "33" },
{ typeof(ReturnAddendumDRecord), "35" },
{ typeof(ImageViewDetailRecord), "50" },
{ typeof(ImageViewDataRecord), "52" },
{ typeof(BundleTrailerRecord), "70" },
{ typeof(CashLetterTrailerRecord), "90" },
{ typeof(FileTrailerRecord), "99" }
};
public static string Get(Type type)
{
return Lut[type];
}
public static Type GetByCode(string recordTypeStr)
{
return Lut.Where(kvp => kvp.Value.Equals(recordTypeStr)).Select(kvp => kvp.Key).FirstOrDefault();
}
public static X9Record Create(string recordTypeStr)
{
Type recordType = Lut.First(kvp => kvp.Value.Equals(recordTypeStr)).Key;
return (X9Record)Activator.CreateInstance(recordType);
}
}
}