Exemplo n.º 1
0
        public T ToCachedComponent <T>(T uncachedComponent) where T : class
        {
            var type = typeof(T);

            if (_configuredTypes.TryGetValue(type, out ConfigurationForType configurationForType))
            {
                return(_proxyFactory.CreateProxyWithTarget(uncachedComponent, configurationForType));
            }
            throw new ArgumentException(string.Format(isNotARegisteredComponentMessage, type));
        }
        public static TClass CreateClassProxy <TClass, TImplement>(this IProxyFactory proxyGenerator, TImplement implement) where TImplement : TClass
            where TClass : class
        {
            var type = typeof(TClass);

            if (!type.IsClass)
            {
                throw new InvalidOperationException($"the Type {type.FullName} is not class");
            }
            return(proxyGenerator.CreateProxyWithTarget <TClass>(implement));
        }
        public static TInterface CreateInterfaceProxy <TInterface, TImplement>(this IProxyFactory proxyGenerator, TImplement implement) where TImplement : TInterface
            where TInterface : class
        {
            var type = typeof(TInterface);

            if (!type.IsInterface)
            {
                throw new InvalidOperationException($"the Type {type.FullName} is not interface");
            }
            return(proxyGenerator.CreateProxyWithTarget <TInterface>(implement));
        }
 public static object CreateProxyWithTarget(this IProxyFactory proxyFactory, Type serviceType, object target)
 {
     return(proxyFactory.CreateProxyWithTarget(serviceType, target, ArrayHelper.Empty <object>()));
 }
 public static TService CreateProxyWithTarget <TService>(this IProxyFactory proxyFactory, object target, object[] arguments)
     where TService : class
 {
     return((TService)proxyFactory.CreateProxyWithTarget(typeof(TService), target, arguments));
 }
 public static TService CreateProxyWithTarget <TService, TImplement>(this IProxyFactory proxyFactory, TImplement target)
     where TImplement : TService
     where TService : class
 {
     return((TService)proxyFactory.CreateProxyWithTarget(typeof(TService), target));
 }