0
我想編寫一個監督和管理項目值的DesignManager類。爲值設置和驗證反饋設計管理器類
項目有很多屬性和相互依賴關係,併爲對方設置了某些值規則。這些值在UI級別輸入到Item變量中,DesignManager檢測變化,進行驗證/計算並向UI報告(通過事件)。
我現在的問題是圍繞屬性setter模式旋轉。我想到了2種方式來完成的關係,各有其利弊/利弊,希望得到建議使用哪一個:
// Syntax is cleaner
// DesignManager does not know about the change Item notifies DesignManager
// Nested collections can notify DesignManager, but there is problem of identifying the sender
DesignManager.Item.Property = value;
// Syntax is not clean
// Hard to support value setting of nested Items or collections within Items
// DesignManager immediately gets informed of the change via the calling UI logic.
DesignManager.SetItemProperty(value);
我不知道我喜歡哪一個,因爲我不能看到所有的注意事項與每一個相關。目前,我最大的問題是嵌套在Item中。
如果有人有這方面的經驗,希望可以建議。謝謝。