Class PublishedModelFactory
Implements a strongly typed content model factory
Inheritance
Namespace: Umbraco.Cms.Core.Models.PublishedContent
Assembly: Umbraco.Core.dll
Syntax
public class PublishedModelFactory : IPublishedModelFactory
Constructors
View SourcePublishedModelFactory(IEnumerable<Type>, IPublishedValueFallback)
Initializes a new instance of the PublishedModelFactory class with types.
Declaration
public PublishedModelFactory(IEnumerable<Type> types, IPublishedValueFallback publishedValueFallback)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.IEnumerable<Type> | types | The model types. |
IPublishedValueFallback | publishedValueFallback |
Remarks
Types must implement IPublishedContent
and have a unique constructor that
accepts one IPublishedContent as a parameter.
To activate,
var types = TypeLoader.Current.GetTypes{PublishedContentModel}();
var factory = new PublishedContentModelFactoryImpl(types);
PublishedContentModelFactoryResolver.Current.SetFactory(factory);
Methods
View SourceCreateModel(IPublishedElement)
Creates a strongly-typed model representing a published element.
Declaration
public IPublishedElement CreateModel(IPublishedElement element)
Parameters
Type | Name | Description |
---|---|---|
IPublishedElement | element | The original published element. |
Returns
Type | Description |
---|---|
IPublishedElement | The strongly-typed model representing the published element, or the published element itself it the factory has no model for the corresponding element type. |
CreateModelList(String)
Creates a List{T} of a strongly-typed model for a model type alias.
Declaration
public IList CreateModelList(string alias)
Parameters
Type | Name | Description |
---|---|---|
System.String | alias | The model type alias. |
Returns
Type | Description |
---|---|
System.Collections.IList | A List{T} of the strongly-typed model, exposed as an IList. |
GetModelType(String)
Gets the Type of a strongly-typed model for a model type alias.
Declaration
public Type GetModelType(string alias)
Parameters
Type | Name | Description |
---|---|---|
System.String | alias | The model type alias. |
Returns
Type | Description |
---|---|
Type | The type of the strongly-typed model. |
MapModelType(Type)
Maps a CLR type that may contain model types, to an actual CLR type.
Declaration
public Type MapModelType(Type type)
Parameters
Type | Name | Description |
---|---|---|
Type | type | The CLR type. |
Returns
Type | Description |
---|---|
Type | The actual CLR type. |
Remarks
See ModelType for more details.