November Happy Hour will be moved to Thursday December 5th.

Class TypeExtensions

Class with extension methods for System.Type

Inheritance
System.Object
TypeExtensions
Namespace: EPiServer.Data.Dynamic
Assembly: EPiServer.Data.dll
Version: 12.0.3
Syntax
public static class TypeExtensions : Object

Methods

CreateStore(Type)

Creates an new Dynamic Data Store for the type If a store with the same name already exists then it will be returned, otherwise the store will be created.

Declaration
public static DynamicDataStore CreateStore(this Type type)
Parameters
Type Name Description
System.Type type

The System.Type to create a store for

Returns
Type Description
DynamicDataStore

A DynamicDataStore instance

Remarks

See CreateStore(Type) for more information

GenerateTypeBag(Type)

Returns a type bag compatible with the Dynamic Data Store CreateStore methods

Declaration
public static Dictionary<string, Type> GenerateTypeBag(this Type type)
Parameters
Type Name Description
System.Type type

The Type to operate on

Returns
Type Description
System.Collections.Generic.Dictionary<System.String, System.Type>

A Dictionary<string, Type>

GetNullableType(Type)

If the type passed is Nullable<T> then the generic parameter at position 0 is returned. If not then type is returned

Declaration
public static Type GetNullableType(this Type type)
Parameters
Type Name Description
System.Type type

The value to check

Returns
Type Description
System.Type

A System.Type

GetOrCreateStore(Type)

Gets the Dynamic Data Store for the type. If a store does not exist for the type then a new one is created.

Declaration
public static DynamicDataStore GetOrCreateStore(this Type type)
Parameters
Type Name Description
System.Type type

The System.Type to get or create a store for

Returns
Type Description
DynamicDataStore

A DynamicDataStore instance

Remarks

See GetStore(Type) and CreateStore(Type) for more information

GetStorageType(Type)

Returns the StorageType for type

Declaration
public static StorageType GetStorageType(this Type type)
Parameters
Type Name Description
System.Type type

The Type to operate on

Returns
Type Description
StorageType

A StorageType

GetStore(Type)

Gets the Dynamic Data Store for the type. If a store does not exist for the type then null is returned.

Declaration
public static DynamicDataStore GetStore(this Type type)
Parameters
Type Name Description
System.Type type

The System.Type to get a store for

Returns
Type Description
DynamicDataStore

A DynamicDataStore instance or null if an existing store does not exist

Remarks

See GetStore(Type) for more information

HasProperty(Type, String)

Returns whether the Type defines the property with name propertyName

Declaration
public static bool HasProperty(this Type type, string propertyName)
Parameters
Type Name Description
System.Type type

The Type to operate on

System.String propertyName

The name of the property to check for

Returns
Type Description
System.Boolean
true
if the Type defines the property, otherwise
false

IsPropertyOfType(Type, String, Type)

Returns whether the Type defines the property with name propertyName and if it is of Type propertyType

Declaration
public static bool IsPropertyOfType(this Type type, string propertyName, Type propertyType)
Parameters
Type Name Description
System.Type type

The Type to operate on

System.String propertyName

The name of the property to check for

System.Type propertyType

The Type the property should be

Returns
Type Description
System.Boolean
true
if the Type defines the property and it is of the Type specified, otherwise
false