2012-08-01 22:06:15 +06:00
|
|
|
|
using System;
|
|
|
|
|
|
|
2012-08-10 13:18:13 +06:00
|
|
|
|
namespace Umbraco.Core.ObjectResolution
|
2012-08-01 22:06:15 +06:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// notes: nothing in Resolving is thread-safe because everything should happen when the app is starting
|
|
|
|
|
|
|
|
|
|
|
|
internal class Resolution
|
|
|
|
|
|
{
|
|
|
|
|
|
public static event EventHandler Frozen;
|
|
|
|
|
|
|
2012-08-01 22:46:13 +06:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Gets a value indicating that resolution is frozen
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <remarks>
|
|
|
|
|
|
/// The internal setter is normally used for unit tests
|
|
|
|
|
|
/// </remarks>
|
|
|
|
|
|
public static bool IsFrozen { get; internal set; }
|
2012-08-01 22:06:15 +06:00
|
|
|
|
|
|
|
|
|
|
public static void EnsureNotFrozen()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (Resolution.IsFrozen)
|
|
|
|
|
|
throw new InvalidOperationException("Resolution is frozen. It is not possible to modify resolvers once resolution is frozen.");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static void Freeze()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (Resolution.IsFrozen)
|
|
|
|
|
|
throw new InvalidOperationException("Resolution is frozen. It is not possible to freeze it again.");
|
|
|
|
|
|
|
|
|
|
|
|
IsFrozen = true;
|
|
|
|
|
|
if (Frozen != null)
|
|
|
|
|
|
Frozen(null, null);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|