c# marking class property as dirty

前端 未结 11 2372
盖世英雄少女心
盖世英雄少女心 2020-11-29 19:32

The following is a simple example of an enum which defines the state of an object and a class which shows the implementation of this enum.

public enum Status         


        
11条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-29 20:13

    Take a look at PostSharp (http://www.postsharp.org/). You can easily create a Attribute which marks it as dirty you can add the attrubute to each property that needs it and it keeps all your code in one place.

    Roughly speaking Create an interface which has your status in make the class implement it. Create an attribute which can be applied on properties and cast to your interface in order to set the value when something changes one of the marked properties.

提交回复
热议问题