在Java中,可以使用动态代理来动态实现接口,类似于以下代码:
在 .Net 中有相应的等价物吗?
public static <T> T createProxy(InvocationHandler invocationHandler, Class<T> anInterface) {
if (!anInterface.isInterface()) {
throw new IllegalArgumentException("Supplied interface must be an interface!");
}
return (T) Proxy.newProxyInstance(anInterface.getClassLoader(), new Class[]{anInterface}, invocationHandler);
}
在 .Net 中有相应的等价物吗?