Class ContentDataFactory<TContentData>

Creates an instance of IContentData instances of specified ContentType.

Inheritance
System.Object
ContentDataFactory<TContentData>
Implements
IContentDataFactory<TContentData>
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: EPiServer.Construction
Assembly: EPiServer.dll
Version: 8.11.0
Syntax
[ServiceConfiguration(typeof(IContentDataFactory<>))]
public class ContentDataFactory<TContentData> : IContentDataFactory<TContentData> where TContentData : IContentData
Type Parameters
Name Description
TContentData

The type of the IContentData to create.

Constructors

ContentDataFactory(IContentDataActivator, IServiceLocator)

Initializes a new instance of the ContentDataFactory<TContentData> class.

Declaration
public ContentDataFactory(IContentDataActivator contentDataActivator, IServiceLocator serviceLocator)
Parameters
Type Name Description
IContentDataActivator contentDataActivator

The activator instance used to instanciate content data objects.

IServiceLocator serviceLocator

The service locator used as a secondary means of creating content data.

Methods

CreateInstance(ContentType)

Creates a new TContentData instance of the specified content type.

Declaration
public virtual TContentData CreateInstance(ContentType contentType)
Parameters
Type Name Description
ContentType contentType

Type indicating what type of content to create.

Returns
Type Description
TContentData

A new TContentData instance.

Exceptions
Type Condition
TypeMismatchException

Thrown if the data type definied by the provided content type does not match the return value type.

CreateInstance(Type)

Creates a new instance of the specified model type.

Declaration
protected virtual TContentData CreateInstance(Type modelType)
Parameters
Type Name Description
System.Type modelType

Type of the model to create.

Returns
Type Description
TContentData

A new instance of the given type.

CreateInstance<TTypedData>()

Creates a new TContentData instance of the type specified by TTypedData.

Declaration
public virtual TTypedData CreateInstance<TTypedData>()

    where TTypedData : TContentData
Returns
Type Description
TTypedData

A new TTypedData instance.

Type Parameters
Name Description
TTypedData

Type indicating what type of content to create.

ResolveContentDataType(String)

Resolves the System.Type of ContentData from the given type and assembly name specified.

Declaration
protected virtual Type ResolveContentDataType(string modelTypeString)
Parameters
Type Name Description
System.String modelTypeString

The model type string.

Returns
Type Description
System.Type

The System.Type that matches the provided type and assembly string.

Remarks

Will return the type of TContentData if the specified type cannot be found. Override this if you want to change this fallback behavior.

Implements

Extension Methods