78 lines
2.5 KiB
C#
78 lines
2.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace Umbraco.Core
|
|
{
|
|
/// <summary>
|
|
/// the Umbraco Application context
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// one per AppDomain, represents the global Umbraco application
|
|
/// </remarks>
|
|
public class ApplicationContext
|
|
{
|
|
/// <summary>
|
|
/// Constructor
|
|
/// </summary>
|
|
/// <param name="pluginResolver"></param>
|
|
public ApplicationContext(PluginResolver pluginResolver)
|
|
{
|
|
Plugins = pluginResolver;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Singleton accessor
|
|
/// </summary>
|
|
public static ApplicationContext Current { get; internal set; }
|
|
|
|
// IsReady is set to true by the boot manager once it has successfully booted
|
|
// note - the original umbraco module checks on content.Instance in umbraco.dll
|
|
// now, the boot task that setup the content store ensures that it is ready
|
|
bool _isReady = false;
|
|
public bool IsReady
|
|
{
|
|
get
|
|
{
|
|
return _isReady;
|
|
}
|
|
internal set
|
|
{
|
|
AssertIsNotReady();
|
|
_isReady = value;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the plugin resolver for the application
|
|
/// </summary>
|
|
public PluginResolver Plugins { get; private set; }
|
|
|
|
// notes
|
|
// GlobalSettings.ConfigurationStatus returns the value that's in the web.config, so it's the "configured version"
|
|
// GlobalSettings.CurrentVersion returns the hard-coded "current version"
|
|
// the system is configured if they match
|
|
// if they don't, install runs, updates web.config (presumably) and updates GlobalSettings.ConfiguredStatus
|
|
//
|
|
// then there is Application["umbracoNeedConfiguration"] which makes no sense... getting rid of it...
|
|
//
|
|
public bool IsConfigured
|
|
{
|
|
// fixme - let's do this for the time being
|
|
get { return umbraco.GlobalSettings.Configured; }
|
|
}
|
|
|
|
private void AssertIsReady()
|
|
{
|
|
if (!this.IsReady)
|
|
throw new Exception("ApplicationContext is not ready yet.");
|
|
}
|
|
|
|
private void AssertIsNotReady()
|
|
{
|
|
if (this.IsReady)
|
|
throw new Exception("ApplicationContext has already been initialized.");
|
|
}
|
|
}
|
|
}
|