public static object CreateDuck(this IInterceptor interceptor, Type proxyType) { var definition = new ProxyDefinition(proxyType, () => null); definition.Implement(() => interceptor); return(definition.CreateProxy()); }
public static T CreateDuck <T>(this IInterceptor interceptor) { var definition = new ProxyDefinition(typeof(T), () => null); definition.Implement(() => interceptor); return(definition.CreateProxy <T>()); }
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>()); }