Closed nhustak closed 5 years ago
There's a version of the FixedLengthReader
constructor accepting the selector: https://github.com/jehugaleahsa/FlatFiles/blob/master/FlatFiles/FixedLengthReader.cs#L41 The multiple schema example in the README is using SeparatedValueReader
but it's the same if you use FixedLengthReader
.
@jehugaleahsa ARGH...I'm an idiot. I see now the reader COMES from the mapper type selector class. Sorry for wasting your time.
Ah, took me a second to see what the problem was, too. Yeah, have to call GetReader. Hmm... I feel like there's an earlier way yet.
GetReader returns an ITypedReader, that you can directly loop over the file with. It will give back objects instead of object arrays. You can just check the current object type as you read.
Yep, thanks after I realized I was barking up the wrong tree on the reader I figured it out. I've used the separated versions quite a bit. This library is a huge time saver. Thank you for sharing it and taking the time to reply to my issues.
Trying to use FixedLengthTypeMapperSelector.
What is the equivalent of SeparatedValueReader for FixedLength?
`var selector = new FixedLengthTypeMapperSelector(); selector.When(values => values.Contains("#M")).Use(CreateMasterMapper()); selector.When(values => values.Contains("#V")).Use(CreateUnitMapper()); selector.When(values => values.Contains("#S")).Use(CreateSummonsMapper());
`
My mappers: private IFixedLengthTypeMapper CreateMasterSchema()
{
var mapper = FixedLengthTypeMapper.Define();