Class Model
This class does not form part of the data model but provide utility methods to help in manipulation of the model.
Inherited Members
Namespace: IAI.DT.DataModel.Utilities
Assembly: IAI.DT.DataModel.dll
Syntax
public class Model
Constructors
Model()
Declaration
public Model()
Methods
GetDataPoint(object, Mapping, bool)
Gets the DataPoint<T> instance for the given mapping in the given object and its value type
Declaration
public static object? GetDataPoint(object target, Mapping mapping, bool create = true)
Parameters
| Type | Name | Description |
|---|---|---|
| object | target | The object containing the values. |
| Mapping | mapping | The mapping to the value of interest. |
| bool | create | When true (the default) the data point path will be created if necessary |
Returns
| Type | Description |
|---|---|
| object | The DataPoint<T> instance for the mapping |
GetInstanceDataPoints(object)
Gets all data points for the provided instance.
Declaration
public static List<(string Path, object Dp)> GetInstanceDataPoints(object o)
Parameters
| Type | Name | Description |
|---|---|---|
| object | o | The instance object |
Returns
| Type | Description |
|---|---|
| List<(string Path, object Dp)> | A List<T> list of (string, object) tuples representing the path and data point of each instance DataPoint<T> |
GetMappedValue(object, Mapping)
Gets the selected value for the specified mapping path from the provided target object
Declaration
public static object? GetMappedValue(object target, Mapping mapping)
Parameters
| Type | Name | Description |
|---|---|---|
| object | target | The target object to read |
| Mapping | mapping | The mapping for the requested value |
Returns
| Type | Description |
|---|---|
| object | The value of the requested item or null. |
GetMappedValue(object, int, Mapping)
Gets the indexed value for the specified mapping path from the provided target object
Declaration
public static object? GetMappedValue(object target, int index, Mapping mapping)
Parameters
| Type | Name | Description |
|---|---|---|
| object | target | The target object to read |
| int | index | The index in the Values array of the value to fetch |
| Mapping | mapping | The mapping for the requested value |
Returns
| Type | Description |
|---|---|
| object | The value of the requested item or null. |
GetTypeMap(Type, bool)
Gets a type map giving the path and property info for every property in the provided type.
Declaration
public static TypeMap GetTypeMap(Type t, bool includeNonPublic = false)
Parameters
| Type | Name | Description |
|---|---|---|
| Type | t | The type to analyze |
| bool | includeNonPublic | Flag indicating if the output type map should include non public properties. |
Returns
| Type | Description |
|---|---|
| TypeMap | The TypeMap instance mapping this type hierarchy. |
GetValuePoint(object, Mapping)
Gets a value from a datapoint based on the provided Mapping
Declaration
public static (object?, PropertyInfo?) GetValuePoint(object target, Mapping mapping)
Parameters
| Type | Name | Description |
|---|---|---|
| object | target | The object containing the values |
| Mapping | mapping | The mapping of the value to get |
Returns
| Type | Description |
|---|---|
| (object, PropertyInfo) | The value of the requested item or null. |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException |
IsNullable(FieldInfo)
Determines whether a field is nullable
Declaration
public static bool IsNullable(FieldInfo field)
Parameters
| Type | Name | Description |
|---|---|---|
| FieldInfo | field | The field to test |
Returns
| Type | Description |
|---|---|
| bool | true where the field is nullable; otherwise false |
IsNullable(PropertyInfo)
Determines whether a property is nullable
Declaration
public static bool IsNullable(PropertyInfo property)
Parameters
| Type | Name | Description |
|---|---|---|
| PropertyInfo | property | The property to test |
Returns
| Type | Description |
|---|---|
| bool | true where the property is nullable; otherwise false |
RemoveDataPoint(object, Mapping)
Sets the specified data point to null
Declaration
public static void RemoveDataPoint(object target, Mapping mapping)
Parameters
| Type | Name | Description |
|---|---|---|
| object | target | The object containing the value to be set. |
| Mapping | mapping | The mapping to the value of interest. |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException |
SetDataPointValue(dynamic, Sources, DateTime, Mapping, dynamic?, string?, bool)
Sets the value associated with the mapping for the target object
Declaration
public static void SetDataPointValue(dynamic dataPoint, Sources source, DateTime mappingTime, Mapping mapping, dynamic? value, string? userId = null, bool overwrite = false)
Parameters
| Type | Name | Description |
|---|---|---|
| dynamic | dataPoint | The DataPoint<T> instance to get the value of |
| Sources | source | The data source of the value |
| DateTime | mappingTime | The time the value was found/received/created |
| Mapping | mapping | The mapping to the value in the data point. |
| dynamic | value | The value to set. |
| string | userId | The userId of the authenticated user making an edit |
| bool | overwrite | When true a matching value in the DataPoint will be overwritten with the new value, when false a matching value will cause an exception |
SetDataPointValue<TV>(DataPoint<TV>, Sources, DateTime, Mapping, TV, string?, string?)
Sets the value associated with the mapping for the target object
Declaration
public static void SetDataPointValue<TV>(DataPoint<TV> dataPoint, Sources source, DateTime mappingTime, Mapping mapping, TV value, string? userId = null, string? note = null)
Parameters
| Type | Name | Description |
|---|---|---|
| DataPoint<TV> | dataPoint | The DataPoint<T> instance to get the value of |
| Sources | source | The data source of the value |
| DateTime | mappingTime | The time the value was found/received/created |
| Mapping | mapping | The mapping to the value in the data point. |
| TV | value | The value to set. |
| string | userId | The userId of the authenticated user making an edit |
| string | note | Comment from Edit Form |
Type Parameters
| Name | Description |
|---|---|
| TV |