Table of Contents

Interface ITypedApiService

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

This is a service to give you Typed Code outside 2sxc.

[PublicApi]
public interface ITypedApiService

Remarks

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

History

  • New in v20

Methods

ApiOfApp(int)

Get an API object for a specific App.

ITypedApi ApiOfApp(int appId)

Parameters

appId int

Returns

ITypedApi

ApiOfApp(int, int)

Get an API object for a specific App.

ITypedApi ApiOfApp(int zoneId, int appId)

Parameters

zoneId int
appId int

Returns

ITypedApi

ApiOfModule(int, int)

Get an API object for a specific Module - the Module must have a 2sxc App or Content on it for this to work.

ITypedApi ApiOfModule(int pageId, int moduleId)

Parameters

pageId int
moduleId int

Returns

ITypedApi

Remarks

This is to work with the content, data or app on this specific module. It is not meant for module-level metadata, which should be on the ApiOfSite.

ApiOfSite()

Get an API object for a current Site/Portal.

ITypedApi ApiOfSite()

Returns

ITypedApi

ApiOfSite(int)

Get an API object for a specified Site/Portal.

ITypedApi ApiOfSite(int siteId)

Parameters

siteId int

Returns

ITypedApi

ApiOfSite(int, int, int)

Get an API object for a specific Site/Portal including proper context of a specific Module on a page.

ITypedApi ApiOfSite(int siteId, int pageId, int moduleId)

Parameters

siteId int
pageId int
moduleId int

Returns

ITypedApi

Remarks

This is the most complex way to get an API, but it will give you the most complete context for your code, which you need for ModuleMetadata.

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

Get the Typed App object for a specific App, which is the most convenient way to work with the content of this App.

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

Parameters

npo NoParamOrder
zoneId int?
appId int?
site ISite
withUnpublished bool?

Returns

IAppTyped

AppOfSite()

Get the Typed App object for the site-wide App, which contains shared data.

IAppTyped AppOfSite()

Returns

IAppTyped