-
-
Notifications
You must be signed in to change notification settings - Fork 3
Deserializable Members
kevin-montrose edited this page Apr 10, 2021
·
4 revisions
When reading data, Cesil takes a number of conceptual steps both per-stream and per-row. The configurable pieces of this process are wrapped in the DeserializableMember
class.
When an IBoundConfiguration<TRow>
is created for a static type, Cesil will using the provided Options to:
- Discover
DeserializableMembers
forTRow
usingITypeDescriber.EnumerateMembersToDeserialize(TypeInfo)
- Discover
SerializableMembers
forTRow
usingITypeDescriber.EnumerateMembersToSerialize(TypeInfo)
- Discover the InstanceProvider for
TRow
usingITypeDescriber.GetInstanceProvider(TypeInfo)
When Cesil begins reading a data stream, it takes the following steps:
- Determine the row ending for the data, if not specified
- This may read some data
- Determine if a header row is present, if not specified
- This may read some data
- If headers are present, columns discovered earlier may be re-ordered to match what's in the stream
Then, for each row it reads, Cesil will:
- Acquire an instance of
TRow
- If using one of the
XXXWithReuseXXX(...)
methods onIReader<TRow>
orIAsyncReader<TRow>
this instance may be provided via theref
parameter, otherwise the discovered InstanceProvider will be used
- If using one of the
- Then, for each cell Cesil will
- Yield the row as appropriate for the called method on
IReader<TRow>
orIAsyncReader<TRow>
Creating DeserializableMembers
DeserializableMembers
exposes many static methods, most of them for convenience.
These families of methods are:
-
ForField(...)
- Automatically discovers unspecified parameters by looking at the given
FieldInfo
- Automatically discovers unspecified parameters by looking at the given
-
ForProperty(...)
- Automatically discovers unspecified parameters by looking at the given
PropertyInfo
- Automatically discovers unspecified parameters by looking at the given
For each of these convenience methods, all parameters must be non-null.
The base method that backs all of these convience methods is DeserializableMember.Create(TypeInfo, string, Setter, Parser, MemberRequired, Reset?)
.