Class ConvertingFieldAccessor<TPin, TObj>
Member Accessor implementation specialized on accessing fields where the type of the pin and the actual type of the field are different. The accessor performs the conversion operation specified when performing its set or get operations.
Inheritance
Implements
Inherited Members
Namespace: Fusee.Xirkit
Assembly: Fusee.Xirkit.dll
Syntax
public class ConvertingFieldAccessor<TPin, TObj> : IMemberAccessor<TPin>
Type Parameters
Name | Description |
---|---|
TPin | The type of the pin. |
TObj | The type of the field. |
Constructors
ConvertingFieldAccessor(FieldInfo, Converter<TPin, TObj>, Converter<TObj, TPin>)
Initializes a new instance of the ConvertingFieldAccessor<TPin, TObj> class.
Declaration
public ConvertingFieldAccessor(FieldInfo fieldInfo, Converter<TPin, TObj> p2o, Converter<TObj, TPin> o2p)
Parameters
Type | Name | Description |
---|---|---|
System.Reflection.FieldInfo | fieldInfo | The field information. |
Converter<TPin, TObj> | p2o | The conversion operation to convert values from the pin type to the field type. |
Converter<TObj, TPin> | o2p | The inverse conversion operation (from field to pin). |
Methods
Get(Object)
Retrieves the value currently stored in the object o. his instance holds information about which field of o the value should be retrieved from and how to perform this retrieval.
Declaration
public TPin Get(object o)
Parameters
Type | Name | Description |
---|---|---|
System.Object | o | The object from which the field identified with this instance's field accessor the value is to be retrieved from. |
Returns
Type | Description |
---|---|
TPin | The value currently stored in o's field. |
Set(Object, TPin)
Sets the specified value to the given object. This instance holds information about which field is to be filled with the value and how to perform this assignment.
Declaration
public void Set(object o, TPin val)
Parameters
Type | Name | Description |
---|---|---|
System.Object | o | The object on which the field identified with this instance's field accessor the given value is to be assigned to. |
TPin | val | The value that should be assigned. |