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>()); }
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)); }
static Func <object, object> GetCtorForType(Type proxyType) { return(StaticFactoryMixin.GetCtor <Func <object, object> >(proxyType)); }