示例#1
0
        public static object CreateDuck(this IInterceptor interceptor, Type proxyType)
        {
            var definition = new ProxyDefinition(proxyType, () => null);

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

            definition.Implement(() => interceptor);
            return(definition.CreateProxy <T>());
        }
示例#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>());
        }