示例#1
0
 public static IUnityContainer RegisterLazy <TFrom, TTo>(
     this IUnityContainer container,
     string name,
     LifetimeManager lifetimeManager,
     params InjectionMember[] injectionMembers)
     where TTo : TFrom
 {
     return(container.RegisterType(
                typeof(TFrom),
                LazyProxyGenerator.GetLazyProxyType <TFrom, TTo>(),
                name, lifetimeManager, injectionMembers));
 }
示例#2
0
 public override void PreBuildUp(IBuilderContext context)
 {
     if (context.Existing == null)
     {
         var policy = context.Policies.Get <ILazyProxyPolicy>(context.OriginalBuildKey);
         if (policy != null)
         {
             var lazyProxyType = LazyProxyGenerator.GetLazyProxyType(policy.ServiceType, policy.ImplementationType);
             context.Existing = context.NewBuildUp(new NamedTypeBuildKey(lazyProxyType, context.OriginalBuildKey.Name));
         }
     }
     base.PreBuildUp(context);
 }