System Library Common Episerver
Search Results for

    DocFx,SystemLibrary.Common.Episerver.Properties.MessageConfig,SystemLibrary.Common.Episerver.Properties.MessageEditorDescriptor,SystemLibrary.Common.Episerver.Properties.MessageProperty,SystemLibrary.Common.Episerver.Properties.MessageController,SystemLibrary.Common.Episerver.Attributes.BoxSelectionController,SystemLibrary.Common.Episerver.Attributes.BoxSelectionFactory,SystemLibrary.Common.Episerver.Attributes.JsonEditController,SystemLibrary.Common.Episerver.Attributes.JsonEditFactory,SystemLibrary.Common.Episerver.Descriptors.HideCategoryListDescriptor,SystemLibrary.Common.Episerver.Properties.ParentLinkReferenceController,SystemLibrary.Common.Episerver.Properties.ParentLinkReferenceEditorDescriptor,SystemLibrary.Common.Episerver.Properties.ParentLinkReferenceProperty,SystemLibrary.Common.Episerver.Attributes.MultiDropdownSelectionController,SystemLibrary.Common.Episerver.Attributes.MultiDropdownSelectionFactory,SystemLibrary.Common.Episerver.Initialize.RemoveSuggestedContentTypes,SystemLibrary.Common.Episerver.Extensions.CommonEpiserverApplicationServicesOptions,SystemLibrary.Common.Episerver.Extensions.CommonEpiserverApplicationBuilderOptions,SystemLibrary.Common.Episerver.EditController,SystemLibrary.Common.Episerver.Abstract.BaseController,SystemLibrary.Common.Episerver.Abstract.BaseMultiSelectionFactory,SystemLibrary.Common.Episerver.ConnectionStringsConfig,SystemLibrary.Common.Episerver.PropertiesConfig,SystemLibrary.Common.Episerver.EditConfig,SystemLibrary.Common.Episerver.Properties.MessageConfig,SystemLibrary.Common.Episerver.FontAwesome,SystemLibrary.Common.Episerver.AppSettings.Configuration,SystemLibrary.Common.Episerver.Attributes.ParentLinkReferenceFactory,SystemLibrary.Common.Episerver.Abstract.InternalBaseController,WebApplicationInitializer
    Show / Hide Table of Contents
    NamespaceSystemLibrary.Common.Episerver SystemLibrary.Common.Episerver.dll

    Base Cms functions to use anywhere within your application

    - No more injecting things that you always need

    - No more fiddling around with where and how do I get the ContentRepository? ServiceLocator? ... do it once, in a Cms class

    BaseCms

    public abstract class BaseCms

    Inheritance
    System.Object
    BaseCms
    Examples
    X
    //Use the BaseCms directly without inheriting it yourself:
    
    var startPage = BaseCms.GetCurrentPage<StartPage>();
    //'startPage' is 'StartPage' is current request is of type 'StartPage', return null else (if you are on an article or inside a block...)
    
    //Extend the BaseCms class with your own Cms functions that are common within your application:
    public class Cms : BaseCms
    {
        public ContentType GetFirstContentType() 
        {
            // Use the ContentTypeRepository, or the ContentRepository or the ContentModelUsage static members that you get when inheriting BaseCms
            return ContentTypeRepository.Load(1);
        }
    }
    Arguments
    X

    Properties

    Protected member you can reuse if you inherit BaseCms

    View Source

    protected static IContentModelUsage ContentModelUsage { get; }

    X
    Property Value
    Type Description
    EPiServer.Core.IContentModelUsage

    Protected member you can reuse if you inherit BaseCms

    View Source

    protected static IContentRepository ContentRepository { get; }

    X
    Property Value
    Type Description
    EPiServer.IContentRepository

    Protected member you can reuse if you inherit BaseCms

    View Source

    protected static IContentTypeRepository ContentTypeRepository { get; }

    X
    Property Value
    Type Description
    EPiServer.DataAbstraction.IContentTypeRepository

    Protected member you can reuse if you inherit BaseCms

    View Source

    protected static IContentVersionRepository ContentVersionRepository { get; }

    X
    Property Value
    Type Description
    EPiServer.Core.IContentVersionRepository

    Returns true if curent request is inside edit mode, else false

    View Source

    public static bool IsInEditMode { get; }

    X
    var isInPreviewMode = BaseCms.IsInPreviewMode;
    X
    Property Value
    Type Description
    System.Boolean

    Returns true if curent request is inside preview mode, else false

    View Source

    public static bool IsInPreviewMode { get; }

    X
    var isInPreviewMode = BaseCms.IsInPreviewMode;
    X
    Property Value
    Type Description
    System.Boolean

    Protected member you can reuse if you inherit BaseCms

    View Source

    protected static ILanguageBranchRepository LanguageBranchRepository { get; }

    X
    Property Value
    Type Description
    EPiServer.DataAbstraction.ILanguageBranchRepository

    The Primary Host Url for the current SIte based on Current Request registered inside 'Managed Websites' in Episerver CMS

    Gets the first primary host type that is not a wildcard and contains a dot

    Fallback to first primary host type that is not a wildcard

    Fallback to first undefined host type that is not a wildcard and contains a dot

    Fallback to first undefined host type that is not a wildcard

    Fallback to Url registered in the Url field of the 'Site'

    Fallback to http://localhost in a non web context

    Remarks
    X

    Returns Primary Host if found

    Fallback to first Undefined Type Host, that is not wildcard and contains a dot (.)

    Fallback again to first Undefined Type Host, that is not wildcard, for instance "localhost:51011"

    Fallback if no host was found, uses the Site Url configred

    Last fallback, if no Site Url, for instance in a non web context (unit test/console), fall back to http://localhost

    Remember to register the proper site and hosts under 'Manage Websites' in Episerver CMS, which requires app restart after configuration changes to take affect
    View Source

    public static string PrimaryHostUrl { get; }

    X
    Property Value
    Type Description
    System.String

    Protected member you can reuse if you inherit BaseCms

    View Source

    protected static ProjectRepository ProjectRepository { get; }

    X
    Property Value
    Type Description
    EPiServer.DataAbstraction.ProjectRepository

    Methods

    CreateHostBuilder()

    Creates a default CMS host builder

    - the 'T' is usually your 'Program.cs' or 'Startup.cs'
    View Source

    public static IHostBuilder CreateHostBuilder<T>(string[] args, string appSettingsFullPath = null, string[] additionalConfigurationsFullPath = null, bool reloadOnConfigChange = false) where T : class

    X

    Program.cs/Startup.cs

    public static void Main(string[] args)
    {
        var appSettingsPath = AppContext.BaseDirectory + "Configs\\AppSettings\\appSettings.json";
        try
        {
            Cms.CreateHostBuilder<Program>(args, appSettingsPath)
                .Build()
                .Run();
        }
        catch (Exception ex)
        {
            Log.Error(ex);
        }
    }
    X
    Generic types
    Name Description
    T
    Methods arguments
    Type Name Description
    System.String[] args
    System.String appSettingsFullPath
    System.String[] additionalConfigurationsFullPath
    System.Boolean reloadOnConfigChange
    X
    Type Description
    Microsoft.Extensions.Hosting.IHostBuilder

    Returns all 'IContent' that either inherits, implements or that is of type T

    - Returns the latest version based on WorkId per ID

    - It filters on Deleted, so no deleted items are returned, but if latest is a Draft, that is returned

    View Source

    public static IEnumerable<T> GetAllLatestVersionsOfContentType<T>() where T : class

    X
    Generic types
    Name Description
    T
    X
    Type Description
    IEnumerable<T>

    Returns all 'ContentType' that either inherits, implements or that is of type T

    View Source

    public static IEnumerable<ContentType> GetContentTypes<T>() where T : class

    X
    Generic types
    Name Description
    T
    X
    Type Description
    IEnumerable<EPiServer.DataAbstraction.ContentType>

    Returns current block as T based on current request and its context [route data], or null

    View Source

    public static T GetCurrentBlock<T>() where T : IContentData

    X
    var currentBlockAsButtonBlock = BaseCms.GetCurrentBlock<ButtonBlock>();
    X
    Generic types
    Name Description
    T
    X
    Type Description
    T

    Returns current page as T based on current request, or null

    View Source

    public static T GetCurrentPage<T>() where T : IContentData

    X
    var currentPageAsStartPage = BaseCms.GetCurrentPage<StartPage>();
    //null if current request is not StartPage
    X
    Generic types
    Name Description
    T
    X
    Type Description
    T

    Extension Methods

    TExtensions.ReactServerSideRender<T>(T, Object, String, Boolean, String, String, String, Boolean, Boolean, Boolean)

    }

    • View Source
    In This Article
    Package: nuget
    Source: github
    Website: System Library Common Episerver