Class DynamicContentFactory

Factory class that handles creating dynamic content object.

Inheritance
System.Object
DynamicContentFactory
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.DynamicContent
Assembly: EPiServer.dll
Version: 8.11.0
Syntax
[ServiceConfiguration(typeof(IDynamicContentFactory), FactoryMember = "Instance")]
public class DynamicContentFactory : IDynamicContentFactory

Constructors

DynamicContentFactory()

Initializes a new instance of the DynamicContentFactory class.

Declaration
public DynamicContentFactory()

DynamicContentFactory(IHashHandler)

Initializes a new instance of the DynamicContentFactory class.

Declaration
public DynamicContentFactory(IHashHandler hashHandler)
Parameters
Type Name Description
IHashHandler hashHandler

The hash handler to use.

DynamicContentFactory(IHashHandler, LocalizationService)

Initializes a new instance of the DynamicContentFactory class.

Declaration
public DynamicContentFactory(IHashHandler hashHandler, LocalizationService localizationService)
Parameters
Type Name Description
IHashHandler hashHandler

The hash handler to use.

LocalizationService localizationService

The resource locator that should be used by the instance to get localized strings.

Properties

DynamicContentId

Gets the GUID used to identify EPiServer dynamic content.

Declaration
public Guid DynamicContentId { get; }
Property Value
Type Description
System.Guid

HashHandler

Gets the hash handler used to generate and validate hashes.

Declaration
public IHashHandler HashHandler { get; }
Property Value
Type Description
IHashHandler

The hash handler.

Instance

Gets the one and only instance of DynamicContentFactory

Declaration
public static DynamicContentFactory Instance { get; }
Property Value
Type Description
DynamicContentFactory

Methods

ClearRegistrations()

Clears the registrations in the factory instance.

Declaration
public void ClearRegistrations()

CreateDynamicContent(String, String, String, Boolean)

Creates a dynamic content control.

Declaration
public IDynamicContentBase CreateDynamicContent(string name, string state, string hash, bool validateHash)
Parameters
Type Name Description
System.String name
System.String state
System.String hash
System.Boolean validateHash
Returns
Type Description
IDynamicContentBase

The created control.

Description(Type)

Returns the descriptions for the specified dynamic content type.

Declaration
public string Description(Type type)
Parameters
Type Name Description
System.Type type

The type.

Returns
Type Description
System.String

A description string.

Remarks

This string will be used as a fallback for description if no description for the dynamic content type can be found in the language files.

GetMarkup(IDynamicContentBase, Boolean, ISecuredFragmentMarkupGenerator)

Gets the XHTML markup for the supplied dynamic content control.

Declaration
public string GetMarkup(IDynamicContentBase dynamicContent, bool generateHash, ISecuredFragmentMarkupGenerator groupMarkupGenerator)
Parameters
Type Name Description
IDynamicContentBase dynamicContent

The dynamic content control.

System.Boolean generateHash

if set to true, generate hash in the markup for validation of state.

ISecuredFragmentMarkupGenerator groupMarkupGenerator

The ISecuredFragmentMarkupGenerator that is responsible to create markup to indicate that the content is restricted to a number of groups.

Returns
Type Description
System.String

A string with HTML that represents the dynamic content.

GetMarkupForEditor(IDynamicContentBase, Boolean, ISecuredFragmentMarkupGenerator)

Gets the markup that is presented when editing.

Declaration
public string GetMarkupForEditor(IDynamicContentBase dynamicContent, bool generateHash, ISecuredFragmentMarkupGenerator groupMarkupGenerator)
Parameters
Type Name Description
IDynamicContentBase dynamicContent

The IDynamicContent to generate markup for.

System.Boolean generateHash

if set to true generate a hash attribute.

ISecuredFragmentMarkupGenerator groupMarkupGenerator

The ISecuredFragmentMarkupGenerator that is responsible to create markup to indicate that the content is restricted to a number of groups.

Returns
Type Description
System.String

Markup that is loaded when loading the dynamic content in edit mode.

InstantiateDynamicContent(String)

Instantiate a dynamic content control.

Declaration
public IDynamicContentBase InstantiateDynamicContent(string name)
Parameters
Type Name Description
System.String name
Returns
Type Description
IDynamicContentBase

The created control.

Name(Type)

Get the name of the specified dynamic content type.

Declaration
public string Name(Type type)
Parameters
Type Name Description
System.Type type

The type.

Returns
Type Description
System.String

The name as a string.

Remarks

This string will be used as a fallback for display name if no display name for the dynamic content type can be found in the language files.

Register(Type, String, String)

Registers the specified dynamic content type.

Declaration
public bool Register(Type type, string name, string description)
Parameters
Type Name Description
System.Type type

The dynamic content type.

System.String name

The name of the dynamic content.

System.String description

The description.

Returns
Type Description
System.Boolean

True if the registration succeeded, otherwise false.

Remarks

The registration will fail if there is already a dynamic content registered with the same name or type.

RegisteredTypes()

Enumerates the registered dynamic contents types.

Declaration
public IEnumerable<Type> RegisteredTypes()
Returns
Type Description
System.Collections.Generic.IEnumerable<System.Type>

An System.Collections.Generic.IEnumerable<T> of System.Type for all the dynamic content types that have been registered.

Implements

Extension Methods