Class ContentTypeModelRegister

Synchronizes ContentTypeModels defined in code with ContentTypes stored in the repository.

Inheritance
System.Object
ContentTypeModelRegister
Namespace: EPiServer.DataAbstraction.RuntimeModel.Internal
Assembly: EPiServer.dll
Version: 12.0.3
Syntax
[ServiceConfiguration]
[ServiceConfiguration]
public class ContentTypeModelRegister : Object, IContentTypeModelRegistrator
Remarks

Model synchronization is automatically performed by this class at site initialization. Please see the examples section for instructions on how you can manually synchronize a content model.

Constructors

ContentTypeModelRegister(ContentTypeSynchronizer, PropertyDefinitionSynchronizer, IContentLoader, ContentModelOptions)

Initializes a new instance of the ContentTypeModelRegister class.

Declaration
public ContentTypeModelRegister(ContentTypeSynchronizer typeSynchronizer, PropertyDefinitionSynchronizer propertyDefinitionSynchronizer, IContentLoader contentLoader, ContentModelOptions contentModelOptions)
Parameters
Type Name Description
ContentTypeSynchronizer typeSynchronizer

The type synchronizer that should be used by this instance.

PropertyDefinitionSynchronizer propertyDefinitionSynchronizer

The property definition synchronizer that should be used by this instance.

IContentLoader contentLoader

The content loader.

ContentModelOptions contentModelOptions

The content model options.

Properties

RunSynchronously

If methods should run without parallellism

Declaration
public bool RunSynchronously { get; set; }
Property Value
Type Description
System.Boolean

TypeModels

Gets the type models that will be used in the Analyze and Commit operations.

Declaration
public IList<ContentTypeModel> TypeModels { get; }
Property Value
Type Description
System.Collections.Generic.IList<ContentTypeModel>

Methods

AnalyzeProperties()

Compares the model's properties to the repository ones

Declaration
public virtual void AnalyzeProperties()

AnalyzeTypes()

Gets the type models properties that will be used in the Analyze of type models properties

Declaration
public virtual void AnalyzeTypes()

CommitProperties(Boolean)

Commits the type models' properties changes detected in the Analyze operation to the repository.

Declaration
public virtual void CommitProperties(bool deleteUnusedTypes)
Parameters
Type Name Description
System.Boolean deleteUnusedTypes

if set to true any types that are no longer used are deleted.

Exceptions
Type Condition
AlreadyInUseException

A definition without an ID, and with a name that already existing definition, tries to be saved.

CommitTypes(Boolean)

Commits any changes detected in the Analyze operation to the repository.

Declaration
public virtual void CommitTypes(bool deleteUnusedTypes)
Parameters
Type Name Description
System.Boolean deleteUnusedTypes

if set to true any types that are no longer used are deleted.

Exceptions
Type Condition
AlreadyInUseException

A definition without an ID, and with a name that already existing definition, tries to be saved.

EnsureContentTypeVersionUpToDate()

Ensures that if there was changes to a content type or its properties, then the assembly version must be updated to reflect which code version that was used to update the database.

Declaration
public void EnsureContentTypeVersionUpToDate()

Validate(ContentModelValidator)

The Validate method checks the contenttypemodels guid and its modeltype. If the guid for the contenttypemodel is not assigned or is empty then it passes validation. If two contenttypes has same guid with different modeltype then SynchronizationException be thrown the validation checks on both contenttypemodels in memory and against repository.

Declaration
public virtual void Validate(ContentModelValidator modelValidator)
Parameters
Type Name Description
ContentModelValidator modelValidator
Exceptions
Type Condition
SynchronizationException

If two or more contenttypes has same guid with different modeltype then SynchronizationException be thrown.

Explicit Interface Implementations

IContentTypeModelRegistrator.RegisterTypes(IEnumerable<ContentTypeModel>, Boolean, Boolean)

Analyzes all models and registers the content types and their property definitions.

Declaration
void IContentTypeModelRegistrator.RegisterTypes(IEnumerable<ContentTypeModel> typeModels, bool deleteUnusedContentTypes, bool deleteUnusedPropertyDefinitions)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<ContentTypeModel> typeModels

List of all content type models that should be registered.

System.Boolean deleteUnusedContentTypes

If set to true any content types that are no longer used are deleted.

System.Boolean deleteUnusedPropertyDefinitions

If set to true any property definitions on that are no longer used are removed from the content type.

Implements

Extension Methods