Click or drag to resize

ValueExpressionParserTApplyDefaultsForTypeTValueExpressionAttribute(IEnumerablePropertyInfo, TypeRegistry) Method

Generates a delegate that will update an instance of type T applying any specified DefaultValueAttribute or TValueExpressionAttribute instances that are declared on the type T properties. Target T instance is accepted as the parameter to the returned delegate ActionT.

Namespace: GSF.ComponentModel
Assembly: GSF.Core (in GSF.Core.dll) Version: 2.4.181-beta
Syntax
public static Action<T> ApplyDefaultsForType<TValueExpressionAttribute>(
	IEnumerable<PropertyInfo> properties = null,
	TypeRegistry typeRegistry = null
)
where TValueExpressionAttribute : Attribute, IValueExpressionAttribute
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.

Return Value

ActionT
Generated delegate that will update T instances with default values applied.
Remarks
This function is useful for generating a delegate to a compiled function that will update objects of type T where properties of the type of have been decorated with DefaultValueAttribute or TValueExpressionAttribute attributes. The updated object will automatically have applied any defined default values as specified by the encountered attributes.
Note  Note
This function will assign evaluated expression values to properties in an existing model.
See Also