LazyOfTComponentLoader
Lazily adds component for Lazy<T>.
using Castle.Core;
using Castle.MicroKernel.Internal;
using Castle.MicroKernel.Registration;
using System;
using System.Reflection;
namespace Castle.MicroKernel.Resolvers
{
[Singleton]
public class LazyOfTComponentLoader : ILazyComponentLoader
{
public IRegistration Load(string name, Type service, Arguments arguments)
{
if (service == (Type)null)
return null;
if (!service.GetTypeInfo().IsGenericType)
return null;
if (service.GetGenericTypeDefinition() != typeof(Lazy<>))
return null;
return Component.For(typeof(Lazy<>)).ImplementedBy(typeof(LazyEx<>), LazyServiceStrategy.Instance).LifeStyle.Transient.NamedAutomatically("castle-auto-lazy");
}
}
}