Class ApplicationContext
the Umbraco Application context
Inheritance
Namespace:System.Dynamic.ExpandoObject
Assembly:Umbraco.Core.dll
Syntax
public class ApplicationContext : IDisposable
Remarks
one per AppDomain, represents the global Umbraco application
Constructors
ApplicationContext(CacheHelper)
Creates a basic app context
Declaration
[Obsolete("Use the other constructor specifying a ProfilingLogger instead")]
public ApplicationContext(CacheHelper cache)
Parameters
Type | Name | Description |
---|---|---|
CacheHelper | cache |
ApplicationContext(CacheHelper, ProfilingLogger)
Creates a basic app context
Declaration
public ApplicationContext(CacheHelper cache, ProfilingLogger logger)
Parameters
Type | Name | Description |
---|---|---|
CacheHelper | cache | |
ProfilingLogger | logger |
ApplicationContext(DatabaseContext, ServiceContext, CacheHelper)
Constructor
Declaration
[Obsolete("Use the other constructor specifying a ProfilingLogger instead")]
public ApplicationContext(DatabaseContext dbContext, ServiceContext serviceContext, CacheHelper cache)
Parameters
Type | Name | Description |
---|---|---|
DatabaseContext | dbContext | |
ServiceContext | serviceContext | |
CacheHelper | cache |
ApplicationContext(DatabaseContext, ServiceContext, CacheHelper, ProfilingLogger)
Constructor
Declaration
public ApplicationContext(DatabaseContext dbContext, ServiceContext serviceContext, CacheHelper cache, ProfilingLogger logger)
Parameters
Type | Name | Description |
---|---|---|
DatabaseContext | dbContext | |
ServiceContext | serviceContext | |
CacheHelper | cache | |
ProfilingLogger | logger |
Properties
ApplicationCache
Returns the application wide cache accessor
Declaration
public CacheHelper ApplicationCache { get; }
Property Value
Type | Description |
---|---|
CacheHelper |
Remarks
Any caching that is done in the application (app wide) should be done through this property
Current
Singleton accessor
Declaration
public static ApplicationContext Current { get; }
Property Value
Type | Description |
---|---|
ApplicationContext |
DatabaseContext
Gets the current DatabaseContext
Declaration
public DatabaseContext DatabaseContext { get; }
Property Value
Type | Description |
---|---|
DatabaseContext |
Remarks
Internal set is generally only used for unit tests
IsConfigured
Declaration
public bool IsConfigured { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
IsReady
Declaration
public bool IsReady { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
IsUpgrading
If the db is configured, there is a database context and there is an umbraco schema, but we are not 'configured' , then it means we are upgrading
Declaration
public bool IsUpgrading { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
ProfilingLogger
Exposes the global ProfilingLogger - this should generally not be accessed via the UmbracoContext and should normally just be exposed on most base classes or injected with IoC
Declaration
public ProfilingLogger ProfilingLogger { get; }
Property Value
Type | Description |
---|---|
ProfilingLogger |
Services
Gets the current ServiceContext
Declaration
public ServiceContext Services { get; }
Property Value
Type | Description |
---|---|
ServiceContext |
Remarks
Internal set is generally only used for unit tests
UmbracoApplicationUrl
The application url.
Declaration
public string UmbracoApplicationUrl { get; }
Property Value
Type | Description |
---|---|
System.String |
Remarks
The application url is the url that should be used by services to talk to the application, eg keep alive or scheduled publishing services. It must exist on a global context because some of these services may not run within a web context. The format of the application url is:
- has a scheme (http or https)
- has the SystemDirectories.Umbraco path
- does not end with a slash It is initialized on the first request made to the server, by UmbracoModule.EnsureApplicationUrl:
- if umbracoSettings:settings/web.routing/@umbracoApplicationUrl is set, use the value (new setting)
- if umbracoSettings:settings/scheduledTasks/@baseUrl is set, use the value (backward compatibility)
- otherwise, use the url of the (first) request. Not locking, does not matter if several threads write to this. See also issues:
- http://issues.umbraco.org/issue/U4-2059
- http://issues.umbraco.org/issue/U4-6788
- http://issues.umbraco.org/issue/U4-5728
- http://issues.umbraco.org/issue/U4-5391
Methods
EnsureContext(ApplicationContext, Boolean)
A method used to set and/or ensure that a global ApplicationContext singleton is created.
Declaration
public static ApplicationContext EnsureContext(ApplicationContext appContext, bool replaceContext)
Parameters
Type | Name | Description |
---|---|---|
ApplicationContext | appContext | The instance to set on the global application singleton |
System.Boolean | replaceContext | If set to true and the singleton is already set, it will be replaced |
Returns
Type | Description |
---|---|
ApplicationContext |
Remarks
This is NOT thread safe
EnsureContext(DatabaseContext, ServiceContext, CacheHelper, Boolean)
A method used to create and ensure that a global ApplicationContext singleton is created.
Declaration
[Obsolete("Use the other method specifying an ProfilingLogger instead")]
public static ApplicationContext EnsureContext(DatabaseContext dbContext, ServiceContext serviceContext, CacheHelper cache, bool replaceContext)
Parameters
Type | Name | Description |
---|---|---|
DatabaseContext | dbContext | |
ServiceContext | serviceContext | |
CacheHelper | cache | |
System.Boolean | replaceContext | If set to true will replace the current singleton instance - This should only be used for unit tests or on app startup if for some reason the boot manager is not the umbraco boot manager. |
Returns
Type | Description |
---|---|
ApplicationContext |
Remarks
This is NOT thread safe
EnsureContext(DatabaseContext, ServiceContext, CacheHelper, ProfilingLogger, Boolean)
A method used to create and ensure that a global ApplicationContext singleton is created.
Declaration
public static ApplicationContext EnsureContext(DatabaseContext dbContext, ServiceContext serviceContext, CacheHelper cache, ProfilingLogger logger, bool replaceContext)
Parameters
Type | Name | Description |
---|---|---|
DatabaseContext | dbContext | |
ServiceContext | serviceContext | |
CacheHelper | cache | |
ProfilingLogger | logger | |
System.Boolean | replaceContext | If set to true will replace the current singleton instance - This should only be used for unit tests or on app startup if for some reason the boot manager is not the umbraco boot manager. |
Returns
Type | Description |
---|---|
ApplicationContext |
Remarks
This is NOT thread safe
ResetUmbracoApplicationUrl()
Resets the url.
Declaration
public void ResetUmbracoApplicationUrl()
WaitForReady(Int32)
Declaration
public bool WaitForReady(int timeout)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | timeout |
Returns
Type | Description |
---|---|
System.Boolean |