November Happy Hour will be moved to Thursday December 5th.

Class DisplayChannelService

Service that handles DisplayChannel instances.

Inheritance
System.Object
DisplayChannelService
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.Web
Assembly: EPiServer.dll
Version: 9.12.2
Syntax
public class DisplayChannelService : IDisplayChannelService, IInitializableModule

Constructors

DisplayChannelService()

Initializes a new instance of the DisplayChannelService class.

Declaration
public DisplayChannelService()

Properties

Channels

Gets all registered channels.

Declaration
public virtual IList<DisplayChannel> Channels { get; }
Property Value
Type Description
System.Collections.Generic.IList<DisplayChannel>

The channels.

EditPath

Gets the edit path Sets the edit path. Main purpose forusing it in tests.

Declaration
public string EditPath { get; set; }
Property Value
Type Description
System.String

PrincipalInfoCreator

Delegate to make PrincipalInfo testable

Declaration
public Func<IPrincipal, PrincipalInfo> PrincipalInfoCreator { get; set; }
Property Value
Type Description
System.Func<System.Security.Principal.IPrincipal, PrincipalInfo>

Methods

GetActiveChannels(HttpContextBase)

Gets all DisplayChannel instances that are considered active for specified context.

Declaration
public virtual IEnumerable<DisplayChannel> GetActiveChannels(HttpContextBase context)
Parameters
Type Name Description
System.Web.HttpContextBase context

The context.

Returns
Type Description
System.Collections.Generic.IEnumerable<DisplayChannel>

Initialize(InitializationEngine)

Initializes this instance.

Declaration
[Obsolete("No longer used as an Initializable Module")]
public void Initialize(InitializationEngine context)
Parameters
Type Name Description
InitializationEngine context

The context.

Remarks

Gets called as part of the EPiServer Framework initialization sequence. Note that it will be called only once per AppDomain, unless the method throws an exception. If an exception is thrown, the initialization method will be called repeadetly for each request reaching the site until the method succeeds.

Initialize(ITypeScannerLookup, IServiceLocator)

Initializes a new instance of the DisplayChannelService class.

Declaration
[Obsolete("Initialize by getting DisplayChannels from type scanner and add to Channels instead")]
public virtual void Initialize(ITypeScannerLookup typeScanner, IServiceLocator serviceLocator)
Parameters
Type Name Description
ITypeScannerLookup typeScanner

The type scanner.

IServiceLocator serviceLocator

The service locator.

RegisterDisplayMode(IDisplayMode)

Registers an System.Web.WebPages.IDisplayMode instance as an DisplayChannel.

Declaration
public virtual void RegisterDisplayMode(IDisplayMode displayMode)
Parameters
Type Name Description
System.Web.WebPages.IDisplayMode displayMode

The display mode.

Examples
  The following example shows the registration of a simple channel for MVC that is active for mobile request.
        public void Initialize(EPiServer.Framework.Initialization.InitializationEngine context)
{
context.Locate.DisplayChannelService()
    .RegisterDisplayMode(new DefaultDisplayMode(RenderingTags.Mobile)
{
    ContextCondition = (r) => r.Request.Browser.IsMobileDevice
});
}

RegisterDisplayMode(IDisplayMode, Int32)

Registers an System.Web.WebPages.IDisplayMode instance as an DisplayChannel.

Declaration
public virtual void RegisterDisplayMode(IDisplayMode displayMode, int index)
Parameters
Type Name Description
System.Web.WebPages.IDisplayMode displayMode

The display mode.

System.Int32 index

The index of where the instance is registered.

Examples
  The following example shows the registration of a simple channel for MVC that is active for mobile request.
        public void Initialize(EPiServer.Framework.Initialization.InitializationEngine context)
{
context.Locate.DisplayChannelService()
    .RegisterDisplayMode(new DefaultDisplayMode(RenderingTags.Mobile)
{
    ContextCondition = (r) => r.Request.Browser.IsMobileDevice
});
}

RegisterDisplayMode(IDisplayMode, Int32, String)

Registers an System.Web.WebPages.IDisplayMode instance as an DisplayChannel.

Declaration
public virtual void RegisterDisplayMode(IDisplayMode displayMode, int index, string resolutionId)
Parameters
Type Name Description
System.Web.WebPages.IDisplayMode displayMode

The display mode.

System.Int32 index

The index of where the instance is registered.

System.String resolutionId

The resolution id.

Examples
  The following example shows the registration of a simple channel for MVC that is active for mobile request.
        public void Initialize(EPiServer.Framework.Initialization.InitializationEngine context)
{
context.Locate.DisplayChannelService()
    .RegisterDisplayMode(new DefaultDisplayMode(RenderingTags.Mobile)
{
    ContextCondition = (r) => r.Request.Browser.IsMobileDevice
});
}

Uninitialize(InitializationEngine)

Resets the module into an uninitialized state.

Declaration
[Obsolete("No longer used as an Initializable Module")]
public void Uninitialize(InitializationEngine context)
Parameters
Type Name Description
InitializationEngine context

The context.

Remarks

This method is usually not called when running under a web application since the web app may be shut down very abruptly, but your module should still implement it properly since it will make integration and unit testing much simpler.

Any work done by Initialize(InitializationEngine) as well as any code executing on InitComplete should be reversed.

Implements

Extension Methods