1

我是extending my Object Property Value Diff但我意識到如果一個對象有太多的屬性,我可能不想區分它們。所以我想出了是否可以使用IoC(如Ninject或其他IoC)動態注入屬性?

public class IgnorePropertyDiffAttribute : System.Attribute 
{ 
} 

這樣我就可以標記我想讓diff忽略的屬性。但是我不想用[IgnorePropertyDiff]污染我的域對象。

public class Role 
{ 
    [IgnorePropertyDiff] 
    public String Description { set; get; } 
    public Double Salary { set; get; } 
    public Boolean HasBonus { set; get; } 
} 

我的問題是,是否有可能使用IoC像Ninject或其他IoC動態注入[IgnorePropertyDiff]?如果我聽起來像一個完全白癡,請執行我,因爲我只是一個初中級別的C#開發人員。提前致謝。

回答

3

屬性是一個編譯時功能,所以不能:您不能使用IoC添加它們(或設置它們的值)。

+0

謝謝。這就是我的想法,但我不是100%肯定的。 – Jeff 2009-01-09 05:33:34