代码之家  ›  专栏  ›  技术社区  ›  Rauhotz

使用Linfu进行动态代理生成

  •  1
  • Rauhotz  · 技术社区  · 16 年前

    我正在尝试为与Linfu的接口构建一个动态代理。代理应该只实现由接口定义的属性的getter方法,并返回例如字典中的值,其中键是属性名。

    link text

    1 回复  |  直到 15 年前
        1
  •  5
  •   Krzysztof Kozmic    15 年前

    尝试:

    // The interceptor class must implement the IInterceptor interface
    var yourInterceptor = new YourInterceptor();
    var proxyFactory = new ProxyFactory();
    IYourInterface proxy = proxyFactory.CreateProxy<IYourInterface>(yourInterceptor);
    // Do something useful with the proxy here...