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

Class SiteDefinition

Holds settings for a site specific definitions like roots for files, blocks etc.

Inheritance
System.Object
SiteDefinition
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
[EPiServerDataTable(TableName = "tblSystemBigTable")]
[ServiceConfiguration(ServiceType = typeof(SiteDefinition), FactoryMember = "Current", Lifecycle = ServiceInstanceScope.Unique)]
[EPiServerDataStore(AutomaticallyRemapStore = true)]
public class SiteDefinition : IReadOnly<SiteDefinition>, IReadOnly

Constructors

SiteDefinition()

Declaration
public SiteDefinition()

Fields

SiteAssetsName

Get the name for the site specific assets folder

Declaration
public const string SiteAssetsName = "SysSiteAssets"
Field Value
Type Description
System.String

WildcardHostName

The wild card host name that is used to map unmapped hosts.

Declaration
public const string WildcardHostName = "*"
Field Value
Type Description
System.String

Properties

ContentAssetsRoot

Gets the reference for the root that holds content related assets.

Declaration
public virtual ContentReference ContentAssetsRoot { get; }
Property Value
Type Description
ContentReference

Current

The instance of SiteDefinition that matches the request. When no site is matched from request or wildcard mapping an empty instance is returned where System can be used to access settings that are not site specific.

Declaration
public static SiteDefinition Current { get; set; }
Property Value
Type Description
SiteDefinition
Remarks

During runtime it will get SiteDefinitionResolver from IOC container and load settings for current site. If repository is not found in container (for example when executed in unit tests) the value will be an SiteDefinition instance with all roots set to EmptyReference

Empty

Gets an empty definition which can be used to access System settings.

Declaration
public static SiteDefinition Empty { get; }
Property Value
Type Description
SiteDefinition
Remarks

This is a singleton instance which can be compared against using object comparison.

GlobalAssetsRoot

Gets the reference for the global assets root.

Declaration
public virtual ContentReference GlobalAssetsRoot { get; }
Property Value
Type Description
ContentReference

Hosts

Gets or sets a list of hosts associated with this site.

Declaration
public virtual IList<HostDefinition> Hosts { get; set; }
Property Value
Type Description
System.Collections.Generic.IList<HostDefinition>

Id

Gets or sets a unique identifier of this site.

Declaration
public virtual Guid Id { get; set; }
Property Value
Type Description
System.Guid

IsReadOnly

Gets a value indicating whether this instance is read only.

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

true if this instance is read only; otherwise, false.

Item[String]

Gets or sets the setting of type System.Object that was registered with the specified key.

Declaration
public virtual object this[string key] { get; set; }
Parameters
Type Name Description
System.String key
Property Value
Type Description
System.Object

The custom settings object registered with the provided key.

Remarks

Any custom settings should be set during initialization.

Name

Identity of site settings instance

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

RootPage

Gets the reference for the root page.

Declaration
public virtual ContentReference RootPage { get; }
Property Value
Type Description
ContentReference

SiteAssetsRoot

Gets or sets the assets root used by this site.

Declaration
public virtual ContentReference SiteAssetsRoot { get; set; }
Property Value
Type Description
ContentReference
Remarks

Setting the value to null means the site does not have a specific asset root meaning global asset root is used.

SiteUrl

Gets or sets the primary site URL.

Declaration
public virtual Uri SiteUrl { get; set; }
Property Value
Type Description
System.Uri
Remarks

The scheme, port and application path will also be used for all added hosts if not set explicitly.

StartPage

Gets or sets the start page of this site.

Declaration
public virtual ContentReference StartPage { get; set; }
Property Value
Type Description
ContentReference

WasteBasket

Gets the reference for the waste basket.

Declaration
public virtual ContentReference WasteBasket { get; }
Property Value
Type Description
ContentReference

Methods

CreateWritableClone()

Creates the writable clone.

Declaration
public virtual SiteDefinition CreateWritableClone()
Returns
Type Description
SiteDefinition

GetHost(String, Boolean)

Gets the HostDefinition from the Hosts property that matches the provided host name.

Declaration
public virtual HostDefinition GetHost(string hostName, bool fallbackToWildcard)
Parameters
Type Name Description
System.String hostName

Name of the host to find.

System.Boolean fallbackToWildcard

if set to true, the wildcard host, if any, will be returned if no directly matching host is found.

Returns
Type Description
HostDefinition

The matching host if found; otherwise null.

GetHosts(CultureInfo, Boolean)

Gets all hosts from the Hosts property that are mapped to the provided language.

Declaration
public virtual IEnumerable<HostDefinition> GetHosts(CultureInfo language, bool fallbackToUnmapped)
Parameters
Type Name Description
System.Globalization.CultureInfo language

The language to return hosts for

System.Boolean fallbackToUnmapped

if set to true all unmapped hosts will be returned if no mapped ones were found.

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

All hosts mapped to the provided language

GetPrimaryHost(CultureInfo)

Gets the primary host for the provided language.

Declaration
public virtual HostDefinition GetPrimaryHost(CultureInfo language)
Parameters
Type Name Description
System.Globalization.CultureInfo language

The language.

Returns
Type Description
HostDefinition

The definition for the host acting as the primary host for the provided language; or if non is found null

Remarks

If no host has been explicitly defined, the first definition found for the provided language is returned. If no host has been defined for the provided language, null will be returned.

MakeReadOnly()

Makes the read only.

Declaration
public void MakeReadOnly()

ThrowIfReadOnly()

Throws an exception if the current instance is read-only.

Declaration
protected virtual void ThrowIfReadOnly()

Explicit Interface Implementations

IReadOnly.CreateWritableClone()

Creates the writable clone.

Declaration
object IReadOnly.CreateWritableClone()
Returns
Type Description
System.Object

Implements

Extension Methods