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 ((object)service == null)
return null;
if (!service.GetTypeInfo().get_IsGenericType())
return null;
if ((object)service.GetGenericTypeDefinition() != typeof(Lazy<>))
return null;
return Component.For(typeof(Lazy<>)).ImplementedBy(typeof(LazyEx<>), LazyServiceStrategy.Instance).LifeStyle.Transient.NamedAutomatically("castle-auto-lazy");
}
}
}