C# Castle.DynamicProxy 2并在运行时添加属性

C# Castle.DynamicProxy 2并在运行时添加属性,c#,c#-2.0,castle-dynamicproxy,C#,C# 2.0,Castle Dynamicproxy,我正在使用Castle.dynamicproxy 2,并将我的代理实例化为: private static T GenerateProxy() { ArrayList addtlInterfaces = new ArrayList(); addtlInterfaces.Add(typeof (INotifyPropertyChanged)); addtlInterfaces.Add(typeof (EntityStatus)); object entit

我正在使用Castle.dynamicproxy 2,并将我的代理实例化为:

private static T GenerateProxy()
{   
    ArrayList addtlInterfaces = new ArrayList();

    addtlInterfaces.Add(typeof (INotifyPropertyChanged));
    addtlInterfaces.Add(typeof (EntityStatus));

    object entityProxy = ProxyGenerator.CreateClassProxy(typeof(T), 
                                                          addtlInterfaces.ToArray(typeof(Type)) as Type[],
                                                          ProxyGenerationOptions.Default,
                                                          new IInterceptor[] { new LazyInterceptor() });


    return (T)entityProxy;
}
我的IEntityStatus界面如下所示:

public interface  IEntityStatus
{
    bool IsDirty
    { get; set;}
}
我需要能够在运行时使用该属性,以便当我的DTO有一个属性更改事件时,该事件可以将DTO设置为dirty。然而,因为它是一个接口,并且没有显式的实现,所以我不知道如何做到这一点。我希望避免为get和set方法创建委托。那么,有没有其他方法来实现我希望实现的目标呢

我意识到我可以设置一个所有活动DTO的集合,当属性更改事件在其中一个DTO上触发时,我可以更新该集合以显示该特定DTO是脏的,但我真的希望该信息成为代理DTO的一部分,以简化语法


期待您的回复

我不知道如何处理INotifyPropertyChanged,但我会对两个接口都使用mixin,让一个订阅另一个的事件。这是一个可行的解决方案吗