Example #1
0
 public Func <InterceptorDecoration, IServiceProvider, object> GetTypeFactory(Type type, InterceptorDecoration interceptors)
 {
     if (_typeFactories.TryGetValue(type, out var factory))
     {
         return(factory);
     }
     lock (_typeFactories)
     {
         if (_typeFactories.TryGetValue(type, out factory))
         {
             return(factory);
         }
         var proxyType = DynamicProxyClassGenerator.CreateVirtualMethodGenerator(type, interceptors).GenerateProxyType();
         return(_typeFactories[type] = CreateTypeFactory(proxyType));
     }
 }
Example #2
0
 public Func <object, InterceptorDecoration, object> GetInstanceFactory(Type type, InterceptorDecoration interceptors)
 {
     if (_instanceFactories.TryGetValue(type, out var factory))
     {
         return(factory);
     }
     lock (_instanceFactories)
     {
         if (_instanceFactories.TryGetValue(type, out factory))
         {
             return(factory);
         }
         var proxyType = DynamicProxyClassGenerator.CreateInterfaceGenerator(type, interceptors).GenerateProxyType();
         return(_instanceFactories[type] = CreateInstanceFactory(proxyType));
     }
 }