LifestyleExtensions
using Castle.MicroKernel.Lifestyle.Scoped;
using Castle.Windsor;
using System;
using System.ComponentModel;
namespace Castle.MicroKernel.Lifestyle
{
[EditorBrowsable(EditorBrowsableState.Never)]
public static class LifestyleExtensions
{
public static IDisposable BeginScope(this IKernel kernel)
{
return new CallContextLifetimeScope(kernel);
}
public static IDisposable RequireScope(this IKernel kernel)
{
if (CallContextLifetimeScope.ObtainCurrentScope() == null)
return kernel.BeginScope();
return null;
}
public static IDisposable BeginScope(this IWindsorContainer container)
{
return new CallContextLifetimeScope(container);
}
public static IDisposable RequireScope(this IWindsorContainer container)
{
if (CallContextLifetimeScope.ObtainCurrentScope() == null)
return container.BeginScope();
return null;
}
}
}