C# Class Felinesoft.UmbracoCodeFirst.Attributes.AutoContentAttribute

Inheritance: ContentFactoryAttribute, IInitialisableAttribute
Datei anzeigen Open project: DanMannMann/UmbracoCodeFirst

Public Methods

Method Description
AutoContentAttribute ( string name, Type parentType = null, int sortOrder = 10 ) : System

When applied to a code-first document type class this attribute instructs the code-first initialiser to create a document instance of that type, if it does not exist. This attribute should only be applied to classes which inherit DocumentTypeBase and which also have a [DocumentType] attribute.

The values for the document instance can either be configured in a parameterless constructor of the document type class or in the InitialiseDefaults method if the class implements IAutoContent

Initialise ( Type targetType ) : void

Initialises the Factory property based on the type to which the attribute is applied.

Protected Methods

Method Description
ConstructFactory ( DocumentTypeBase values ) : IContentFactory

Automatically constructs a factory for any inheritor of DocumentTypeBase

GetValues ( Type targetType ) : DocumentTypeBase

Gets the document instance values for use in creating the default content

Method Details

AutoContentAttribute() public method

When applied to a code-first document type class this attribute instructs the code-first initialiser to create a document instance of that type, if it does not exist. This attribute should only be applied to classes which inherit DocumentTypeBase and which also have a [DocumentType] attribute.

The values for the document instance can either be configured in a parameterless constructor of the document type class or in the InitialiseDefaults method if the class implements IAutoContent

public AutoContentAttribute ( string name, Type parentType = null, int sortOrder = 10 ) : System
name string The name of the document node
parentType System.Type /// The type whose default document will be the parent of this document. /// The supplied type must inherit DocumentTypeBase and must specify a default content provider via an [AutoContent] or [ContentFactory] attribute ///
sortOrder int The sort order for the document amongst its' siblings
return System

ConstructFactory() protected method

Automatically constructs a factory for any inheritor of DocumentTypeBase
protected ConstructFactory ( DocumentTypeBase values ) : IContentFactory
values DocumentTypeBase The document type to create
return IContentFactory

GetValues() protected method

Gets the document instance values for use in creating the default content
protected GetValues ( Type targetType ) : DocumentTypeBase
targetType System.Type The document type
return DocumentTypeBase

Initialise() public method

Initialises the Factory property based on the type to which the attribute is applied.
public Initialise ( Type targetType ) : void
targetType System.Type The type to which the attribute is applied
return void