-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Master/detail implementation for #23 #24
Conversation
Sync with upstream dev branch
Disable some resharper warnings
Here's a usage example: // 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;
});
// Read file
using (var stream = File.OpenRead(file))
engine.Read(stream);
var transactions = engine.GetRecords<TransactionRecord>().ToList();
// Get detail records
foreach (var detailRecord in transaction.DetailRecords.OfType<TransactionDetailRecord>())
detailRecord.TransactionId = transaction.Id; It's not quite as abstracted as the engine is (e.g. |
@petersondrew, it looks good.
// 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;
}); Let's me explain why:
I can merge you changes without any problems, but could you please spend some time on rethinking about the initialization (maybe some kind of the Thank you for you great help. Pavel. |
Thanks for the feedback @forcewake . Just an FYI - the engine code initialization hasn't changed since it was created 😉 As for coming up with some sort of engine configuration class, I think that's a good idea. Also note that you can pass a named function rather than an anonymous one for better code re-use on the initialization. For this PR though, nothing has changed with the API for the multi-record engine. Just the support for the |
Yes, I will create another issue. Good idea. 👍
My fault 😢 I will merge and close this PR Thank you for help. |
Master/detail implementation for #23
This PR implements a solution for #23 and associated tests.
Please let me know if you'd like any changes to the API, it's pretty basic and I didn't give it a ton of thought.