Let's say I have a this fixed length string:
ABBCCC10purple crayon5 red pencil9 green marker
The A, B, and C fields are easily mapped:
[FixedLengthRecord]
public class OutterRecord
{
[FieldFixedLength(1)]
public string AField { get; set; }
[FieldFixedLength(2)]
public string BField { get; set; }
[FieldFixedLength(3)]
public string CField { get; set; }
}
However, the remaining part of the line is an array of objects. For example, let's say 10purple crayon is:
[FixedLengthRecord]
public class WritingInstrument
{
[FieldFixedLength(2)]
public string Count { get; set; }
[FieldFixedLength(7)]
public string Color { get; set; }
[FieldFixedLength(6)]
public string TypeOfInstrument { get; set; }
}
Is there a way in FileHelpers to parse the WritingIntsturments section? Given the constraint/limitation that each individual WritingInstrument record is a max of 15 characters wide, and there can be at most 10 items in the array.
I want the resulting deserialized object to look like this:
[FixedLengthRecord]
public class OutterRecord
{
[FieldFixedLength(1)]
public string AField { get; set; }
[FieldFixedLength(2)]
public string BField { get; set; }
[FieldFixedLength(3)]
public string CField { get; set; }
[SomeTypeOfFixedArray(10)]
List<WritingInstrument> WritingInstruments { get; set; }
}
You can just declare a field of type
string[].Here's a working program: