Table of Contents

Interface IDynamicCodeService

Namespace
ToSic.Sxc.Services
Assembly
ToSic.Sxc.dll

This is a service to give you DynamicCode outside of 2sxc.

Use this to access 2sxc data from a Theme, a .ascx WebControl or anywhere else.

[PublicApi]
public interface IDynamicCodeService

Remarks

  • New in v13.02
  • This is meant to replace the ToSic.Sxc.Dnn.Factory. Please use this from now on.

Methods

App(NoParamOrder, int?, int?, ISite, bool?)

Get a rich IApp object for a specific App. This is the simplest way to work with data of this App, but won't give you commands like AsDynamic(...)

IApp App(NoParamOrder noParamOrder = default, int? zoneId = null, int? appId = null, ISite site = null, bool? withUnpublished = null)

Parameters

noParamOrder NoParamOrder

see Convention: Named Parameters

zoneId int?

The ZoneId of the App (optional)

appId int?

The AppId - REQUIRED

site ISite

Site information for further context (optional)

withUnpublished bool?

Determines if the App.Data gives you unpublished data (like in admin-mode) or just published data. If not set, will default to user permissions.

Returns

IApp

An initialized App object which you can use to access App.Data

AppOfSite()

Get a rich IApp object for the primary (aka Site) App of the current Site/Portal and using permissions of the current user. This is the simplest way to work with data of this App, but won't give you commands like AsDynamic(...). For more control, use the AppOfSite with parameters.

IApp AppOfSite()

Returns

IApp

AppOfSite(NoParamOrder, int?, ISite, bool?)

Get a rich IApp object for the primary (aka Site) App. This is the simplest way to work with data of this App, but won't give you commands like AsDynamic(...)

IApp AppOfSite(NoParamOrder noParamOrder = default, int? siteId = null, ISite site = null, bool? withUnpublished = null)

Parameters

noParamOrder NoParamOrder

see Convention: Named Parameters

siteId int?

The SiteId which is the PortalId in DNN. Optional - without it, the current Site / Portal is used.

site ISite

Site information for further context (optional)

withUnpublished bool?

Determines if the App.Data gives you unpublished data (like in admin-mode) or just published data. If not set, will default to user permissions.

Returns

IApp

An initialized App object which you can use to access App.Data

OfApp(int)

Get a ToSic.Sxc.Code.Internal.IDynamicCode12 object for a specific App. This is the simplest way to work with Dynamic Code for this App.

Note that this is without Page/Module context, so there will be no useful Content object on the dynamic code.

IDynamicCode12 OfApp(int appId)

Parameters

appId int

The AppId

Returns

IDynamicCode12

The dynamic code object for this App

OfApp(int, int)

Get a ToSic.Sxc.Code.Internal.IDynamicCode12 object for a specific App. This is the simplest way to work with Dynamic Code for this App.

Note that this is without Page/Module context, so there will be no useful Content object on the dynamic code.

IDynamicCode12 OfApp(int zoneId, int appId)

Parameters

zoneId int

The ZoneId of the App

appId int

The AppId

Returns

IDynamicCode12

The dynamic code object for this App

OfApp(IAppIdentity)

Get a ToSic.Sxc.Code.Internal.IDynamicCode12 object for a specific App. This is the simplest way to work with Dynamic Code for this App.

Note that this is without Page/Module context, so there will be no useful Content object on the dynamic code.

IDynamicCode12 OfApp(IAppIdentity appIdentity)

Parameters

appIdentity IAppIdentity

The App Identifier

Returns

IDynamicCode12

The dynamic code object for this App

OfModule(int, int)

Get a ToSic.Sxc.Code.Internal.IDynamicCode12 object for a specific Module on a page

IDynamicCode12 OfModule(int pageId, int moduleId)

Parameters

pageId int
moduleId int

Returns

IDynamicCode12

OfSite()

Get a ToSic.Sxc.Code.Internal.IDynamicCode12 object for the primary App of the current Site/Portal.

IDynamicCode12 OfSite()

Returns

IDynamicCode12

OfSite(int)

Get a ToSic.Sxc.Code.Internal.IDynamicCode12 object for a specific Site/Portal.

IDynamicCode12 OfSite(int siteId)

Parameters

siteId int

Returns

IDynamicCode12