Esempio n. 1
0
        public void FactoryForDefaultCtor()
        {
            var pcd = new ProxyClassDescriptor(
                new StaticFactoryMixin(typeof(Sample).GetConstructor(Type.EmptyTypes)));
            var proxyType = ProxyModule.Default.GetTypeFromProxyClassDescriptor(pcd);
            var ctor      = StaticFactoryMixin.GetCtor <Func <object> >(proxyType);
            var result    = ctor();

            Assert.That(result, Is.Not.Null);
            Assert.That(result, Is.TypeOf <Sample>());
        }
Esempio n. 2
0
        public object GetSafeProxyForType(Type type, object target)
        {
            Func <object, object> ctor;

            if (!_safeCtorCache.TryGetValue(type, out ctor))
            {
                var pcd = new ProxyClassDescriptor(
                    new StaticFactoryMixin(),
                    new RealSubjectMixin(type, new SafeDirectProxySubject(type), new SafeProxyMetaSubject()),
                    new MethodExistsProxyMetaMixin());
                Type proxyType = _proxyModule.GetTypeFromProxyClassDescriptor(pcd);
                ctor = _safeCtorCache.GetOrAdd(type, StaticFactoryMixin.GetCtor <Func <object, object> >(proxyType));
            }
            return(ctor(target));
        }
Esempio n. 3
0
 static Func <object, object> GetCtorForType(Type proxyType)
 {
     return(StaticFactoryMixin.GetCtor <Func <object, object> >(proxyType));
 }