Class DeserializerMemberAttribute
Attach this attribute to a method, field, property, or parameter to expose it as deserializable and configure it's "Parser", "MemberRequired", "Reset", and "Order" behaviors.
If attached to a property, the propery must have a setter and take no parameters.
If attached to a method it must return void.
If attached to a parameter, the parameter must be to a constructor, all parameters to the constructor must also be annotated, and the constructor itself must be annotated with DeserializerInstanceProviderAttribute.
If attached to a static method it may:
- take 1 parameter (the result of the parser) or
- take 2 parameters, the result of the parser and an
in ReadContext
or - take 2 parameters, the row type (which may be passed by ref), and the result of the parser or
- take 3 parameters, the row type (which may be passed by ref), the result of the parser, and
in ReadContext
If attached to an instance method it may:
- be on the row type, and take 1 parameter (the result of the parser) or
- be on the row type, and take 2 parameters, the result of the parser and an
in ReadContext
Inheritance
Implements
Namespace: Cesil
Assembly: Cesil.dll
Syntax
public sealed class DeserializerMemberAttribute : Attribute, IEquatable<DeserializerMemberAttribute>
Constructors
DeserializerMemberAttribute()
Create a GenerateDeserializableAttribute attribute.
Declaration
public DeserializerMemberAttribute()
Properties
HasOrder
Returns true if Order has been explicitly set.
Getting Order when HasOrder is false will throw an exception.
Declaration
public bool HasOrder { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
MemberRequired
Whether or not this column is required.
Defaults to No, except for on constructor parameters (where it must be Yes).
Declaration
public MemberRequired MemberRequired { get; set; }
Property Value
Type | Description |
---|---|
MemberRequired |
Name
The name of the column which maps to this member.
For fields and properties, this defaults to their declared name.
For methods, this must be explicitly set.
Declaration
public string Name { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Order
Value used to order columns.
Set to null to leave order unspecified.
Orders with explicit values are sorted before those without values.
Check HashOrder before getting Order, or an exception will be thrown.
Declaration
public int Order { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
ParserMethodName
Name of parser method, used with ParserType.
If non-null, ParserType must also be set.
The method must:
- be static
- return a bool
- have 3 parameters
- ReadOnlySpan(char)
- in ReadContext,
- out assignable to outputType
Declaration
public string ParserMethodName { get; set; }
Property Value
Type | Description |
---|---|
System.String |
ParserType
Type to lookup a parser method on, used with ParserMethodName.
If null, defaults to a built in Parser for the type of this member (if any).
If non-null, ParserMethodName must also be set.
The type must be public (or internal, if declared in the same assembly as the annotated type).
Declaration
public Type ParserType { get; set; }
Property Value
Type | Description |
---|---|
System.Type |
ResetMethodName
Name of reset method, used with ResetType.
If non-null, ResetType must also be set.
The method must return void.
If referring to an instance method it can take:
- zero parameters or
- a single
in ReadContext
parameter.
If referring to a static method it can take:
- zero parameters or
- a single parameter of the row type or
- a single parameter of
in ReadContext
or - two parameters, the first of the row type (which may be by ref) and the second of
in ReadContext
Declaration
public string ResetMethodName { get; set; }
Property Value
Type | Description |
---|---|
System.String |
ResetType
Type to lookup a reset method on, used with ResetMethodName.
If non-null, ResetMethodName must also be set.
Declaration
public Type ResetType { get; set; }
Property Value
Type | Description |
---|---|
System.Type |
Methods
Equals(DeserializerMemberAttribute)
Returns true if the given DeserializerMemberAttribute is equal to this one.
Declaration
public bool Equals(DeserializerMemberAttribute attribute)
Parameters
Type | Name | Description |
---|---|---|
DeserializerMemberAttribute | attribute |
Returns
Type | Description |
---|---|
System.Boolean |
Equals(Object)
Return true if the given object is a DeserializerMemberAttribute equal to this one.
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
System.Object | obj |
Returns
Type | Description |
---|---|
System.Boolean |
GetHashCode()
Returns a stable hash code for this DeserializerMemberAttribute.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
System.Int32 |
ToString()
Returns a representation of this DeserializerMemberAttribute object.
Only for debugging, this value is not guaranteed to be stable.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String |
Operators
Equality(DeserializerMemberAttribute, DeserializerMemberAttribute)
Compare two DeserializerMemberAttribute for equality
Declaration
public static bool operator ==(DeserializerMemberAttribute a, DeserializerMemberAttribute b)
Parameters
Type | Name | Description |
---|---|---|
DeserializerMemberAttribute | a | |
DeserializerMemberAttribute | b |
Returns
Type | Description |
---|---|
System.Boolean |
Inequality(DeserializerMemberAttribute, DeserializerMemberAttribute)
Compare two DeserializerMemberAttribute for inequality
Declaration
public static bool operator !=(DeserializerMemberAttribute a, DeserializerMemberAttribute b)
Parameters
Type | Name | Description |
---|---|---|
DeserializerMemberAttribute | a | |
DeserializerMemberAttribute | b |
Returns
Type | Description |
---|---|
System.Boolean |