Esempio n. 1
0
        public static object CreateDuck(this IInterceptor interceptor, Type proxyType)
        {
            var definition = new ProxyDefinition(proxyType, () => null);

            definition.Implement(() => interceptor);
            return(definition.CreateProxy());
        }
Esempio n. 2
0
        public static T CreateDuck <T>(this IInterceptor interceptor)
        {
            var definition = new ProxyDefinition(typeof(T), () => null);

            definition.Implement(() => interceptor);
            return(definition.CreateProxy <T>());
        }
Esempio n. 3
0
        public static T CreateDuck <T>(this object target)
            where T : class
        {
            if (target is IMethodInvoker invoker)
            {
                return(invoker.CreateDuck <T>());
            }

            var definition = new ProxyDefinition(typeof(T), () => null);

            definition.Implement(() => new DuckTypeInterceptor(target));
            return(definition.CreateProxy <T>());
        }