diff --git a/Lawo.EmberPlusSharp/Model/Element.cs b/Lawo.EmberPlusSharp/Model/Element.cs index 92e003a4..c21fb03c 100644 --- a/Lawo.EmberPlusSharp/Model/Element.cs +++ b/Lawo.EmberPlusSharp/Model/Element.cs @@ -65,20 +65,8 @@ public string Description /// public bool IsOnline { - get - { - return this.isOnline; - } - - internal set - { - var oldValue = this.RetrieveDetails; - - if (this.SetValue(ref this.isOnline, value)) - { - this.AdaptRetrieveDetailsChangeStatus(oldValue); - } - } + get { return this.isOnline; } + internal set { this.SetRetrieveDetailsChangeStatus(() => this.SetValue(ref this.isOnline, value)); } } /// @@ -141,9 +129,11 @@ internal virtual bool RetrieveDetails internal RetrieveDetailsChangeStatus RetrieveDetailsChangeStatus { get; set; } - internal void AdaptRetrieveDetailsChangeStatus(bool oldValue) + internal void SetRetrieveDetailsChangeStatus(Func setValue) { - if (this.RetrieveDetails != oldValue) + var oldValue = this.RetrieveDetails; + + if (setValue() && (this.RetrieveDetails != oldValue)) { // We're deliberately not simply setting this to Changed here, because we want to correctly handle // the case when IsOnline is changed twice without being observed between the changes. diff --git a/Lawo.EmberPlusSharp/Model/NodeBase.cs b/Lawo.EmberPlusSharp/Model/NodeBase.cs index 80ff0ce9..d5291ac3 100644 --- a/Lawo.EmberPlusSharp/Model/NodeBase.cs +++ b/Lawo.EmberPlusSharp/Model/NodeBase.cs @@ -53,9 +53,7 @@ public ChildrenRetrievalPolicy ChildrenRetrievalPolicy "value"); } - var oldValue = this.RetrieveDetails; - this.SetValue(ref this.childrenRetrievalPolicy, value); - this.AdaptRetrieveDetailsChangeStatus(oldValue); + this.SetRetrieveDetailsChangeStatus(() => this.SetValue(ref this.childrenRetrievalPolicy, value)); } } }