Beispiel #1
0
        public void InheritWhenNoConstructorsInterface()
        {
            var proxyType = creator.CreateProxyType(typeof(INoConstructorsInterface));

            Assert.Equal("INoConstructorsInterface_Proxy_Inherit", proxyType.Name);
            var v = Activator.CreateInstance(proxyType, new object[] { new TestInterceptorFactory() }) as INoConstructorsInterface;

            Assert.NotNull(v);
        }
Beispiel #2
0
        public void InheritWhenNoConstructorsInterface()
        {
            var proxyType = creator.CreateProxyType(typeof(FieldsTestClass));

            Assert.Equal("FieldsTestClass_Proxy_Inherit", proxyType.Name);
            var v = Activator.CreateInstance(proxyType, new object[] { new TestInterceptorFactory() }) as FieldsTestClass;

            Assert.NotNull(v);
            Assert.Equal(0, v.PublicInt);
            Assert.Equal(0, v.ProtectedInternalInt);
        }
Beispiel #3
0
        public ServiceDescriptor Convert(ServiceDescriptor descriptor)
        {
            var type = creator.CreateProxyType(descriptor.ServiceType, ProxyTypes.Facade);

            return(ServiceDescriptor.Describe(descriptor.ServiceType, i =>
            {
                var proxy = ActivatorUtilities.CreateInstance(i, type);
                var f = proxy.GetType().GetField("instance", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
                f.SetValue(proxy, descriptor.ImplementationFactory != null
                    ? descriptor.ImplementationFactory(i)
                    : (descriptor.ImplementationInstance != null ? descriptor.ImplementationInstance : ActivatorUtilities.CreateInstance(i, descriptor.ImplementationType)));
                return proxy;
            }, descriptor.Lifetime));
        }
        public ServiceDescriptor Convert(ServiceDescriptor descriptor)
        {
            var serviceType = descriptor.ServiceType;

            return(ServiceDescriptor.Describe(serviceType, creator.CreateProxyType(serviceType), descriptor.Lifetime));
        }
 public ServiceDescriptor Convert(ServiceDescriptor descriptor)
 {
     return(ServiceDescriptor.Describe(descriptor.ServiceType, creator.CreateProxyType(descriptor.ImplementationType), descriptor.Lifetime));
 }