FlatFile
FlatFile copied to clipboard
Rethinking of the engine code initialization. Refer to #24
This is the continuation of the conversation from the https://github.com/forcewake/FlatFile/pull/24#issuecomment-102088350
// Init multi record file engine
var engine =
EngineFactory.GetEngine(
new[]
{
typeof (SettlementHeaderRecord),
typeof (TransactionRecord),
typeof (TransactionDetailRecord),
typeof (SettlementTrailerRecord)
},
s =>
{
if (String.IsNullOrEmpty(s) || s.Length < 1) return null;
switch (s[0])
{
case 'H':
return typeof(SettlementHeaderRecord);
case 'D':
return typeof(TransactionRecord);
case 'P':
return typeof(TransactionDetailRecord);
case 'V':
return typeof(SettlementTrailerRecord);
}
return null;
});
- It's rather hard to read
- It's rather hard to extend in future
- When we will have a lot of engines we will have a lot of copy-paste code