Click or drag to resize

ValueExpressionParserTCreateInstanceForTypeTValueExpressionAttribute, TExpressionScope(IEnumerablePropertyInfo, TypeRegistry) Method

Generates a delegate that will create new instance of type T accepting a contextual IValueExpressionScopeT object parameter applying any specified DefaultValueAttribute or TValueExpressionAttribute instances that are declared on the type T properties.

Namespace: GSF.ComponentModel
Assembly: GSF.Core (in GSF.Core.dll) Version: 2.4.181-beta
Syntax
public static Func<TExpressionScope, T> CreateInstanceForType<TValueExpressionAttribute, TExpressionScope>(
	IEnumerable<PropertyInfo> properties = null,
	TypeRegistry typeRegistry = null
)
where TValueExpressionAttribute : Attribute, IValueExpressionAttribute
where TExpressionScope : Object, IValueExpressionScope<T>
View Source

Parameters

properties  IEnumerablePropertyInfo  (Optional)
Specific properties to target, or null to target all properties.
typeRegistry  TypeRegistry  (Optional)
Type registry to use when parsing TValueExpressionAttribute instances, or null to use DefaultTypeRegistry.

Type Parameters

TValueExpressionAttribute
IValueExpressionAttribute parameter type.
TExpressionScope
IValueExpressionScopeT parameter type.

Return Value

FuncTExpressionScope, T
Generated delegate that will create new T instances with expression values applied.
Remarks
This function is useful for generating a delegate to a compiled function that will create new objects of type T where properties of the type of have been decorated with DefaultValueAttribute or TValueExpressionAttribute attributes. The newly created object will automatically have applied any defined default values as specified by the encountered attributes. The generated delegate takes a parameter to a contextual object useful for providing extra runtime data to TValueExpressionAttribute attributes; the parameter must be derived from IValueExpressionScopeT. Any public fields, methods or properties defined in the derived class will be automatically accessible from the expressions declared in the TValueExpressionAttribute attributes. By default, the expressions will have access to the current T instance by referencing the this keyword, which is an alias to Instance.
Note  Note
This function will assign evaluated expression values to properties in a newly created model.
See Also