C# - Can FileHelper FieldConverter routines refer to other fields in the record?
Posted
by Pete
on Stack Overflow
See other posts from Stack Overflow
or by Pete
Published on 2010-03-26T06:53:37Z
Indexed on
2010/03/29
1:23 UTC
Read the original article
Hit count: 617
I am using the excellent FileHelpers library to process a fixed-length airline schedule file.
I have a date field, then a few fields later on in the record, a time field.
I want to combine both of these in the FileHelpers record class, and know there is a custom FieldConverter
attribute. With this attribute, you provide a custom function to handle your field data and implement StringToField
and FieldToString
.
My question is: can I pass other fields (already read) to this customer FieldConverter
too, so I can combine Date and Time together. FieldConverter
has an implementation that allows you to refer to both a custom processing class AND 'other strings' or even an array of object. But, given this is done in the attribute definition, I am struggling to access this earlier-field reference.
[FieldFixedLength(4)]
[FieldConverter(typeof(MyTimeConverter),"eg. ScheduledDepartureDate")]
public DateTime scheduledDepartureTime;
© Stack Overflow or respective owner