-
Notifications
You must be signed in to change notification settings - Fork 4
Getting Started
Michael Scribellito edited this page Jul 20, 2018
·
4 revisions
To start using FixedWidth, begin by applying attributes to your class and members (fields & properties).
-
TextSerializable
indicates that a class is serializable. -
TextField
indicates that a field or property is serializable.
[TextSerializable]
public class Dog
{
[TextField(1, 10)]
public string Name { get; set; }
[TextField(11, 1)]
public char Sex { get; set; }
[TextField(12, 3,
Padding = '0',
Alignment = TextAlignment.Right)]
public int Weight { get; set; }
[TextField(15, 8,
FormatterType = typeof(DateFormatter))]
public DateTime BirthDate { get; set; }
[TextField(23, 1,
FormatterType = typeof(BooleanFormatter))]
public bool SpayedNeutered { get; set; }
}
// create serializer
var serializer = new TextSerializer<Dog>();
// deserialize string
var deserialized = serializer.Deserialize("Wally M065201011161");
// serialize object
var serialized = serializer.Serialize(deserialized);
Next >> Recommended Usage