Gemstone Expressions Library
Show/Hide TOC

# ValueExpressionParser T CreateInstanceForType TValueExpressionAttribute(IEnumerablePropertyInfo, TypeRegistry) Method

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

## Definition

Namespace: Gemstone.Expressions.Model
Assembly: Gemstone.Expressions (in Gemstone.Expressions.dll) Version: 1.0.164 -- Release Build+0b8b4f25483dbf776f178d6e345f9c593290449b
C#
View Source Request Example

    public static Func<T> CreateInstanceForType<TValueExpressionAttribute>(
    	IEnumerable<PropertyInfo>? properties = null,
    	TypeRegistry? typeRegistry = null
    )
    where TValueExpressionAttribute : Attribute, IValueExpressionAttribute

VB
View Source Request Example

    Public Shared Function CreateInstanceForType(Of TValueExpressionAttribute As {Attribute, IValueExpressionAttribute}) (
    	Optional properties As IEnumerable(Of PropertyInfo) = Nothing,
    	Optional typeRegistry As TypeRegistry = Nothing
    ) As Func(Of T)

C++
View Source Request Example

    public:
    generic<typename TValueExpressionAttribute>
    where TValueExpressionAttribute : Attribute, IValueExpressionAttribute
    static Func<T>^ CreateInstanceForType(
    	IEnumerable<PropertyInfo^>^ properties = nullptr,
    	TypeRegistry^ typeRegistry = nullptr
    )

JavaScript
View Source Request Example

    JavaScript does not support generic types or methods.

#### Parameters

properties IEnumerable PropertyInfo (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

Func T
Generated delegate that will create new T instances with default 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.

Note

This function will assign evaluated expression values to properties in a newly created model.

## See Also

#### Reference

ValueExpressionParserT Class
CreateInstanceForType Overload
Gemstone.Expressions.Model Namespace