diff --git a/Lawo.EmberPlusSharp/Lawo.EmberPlusSharp.csproj b/Lawo.EmberPlusSharp/Lawo.EmberPlusSharp.csproj index 21d0b5b8..048a0e18 100644 --- a/Lawo.EmberPlusSharp/Lawo.EmberPlusSharp.csproj +++ b/Lawo.EmberPlusSharp/Lawo.EmberPlusSharp.csproj @@ -124,7 +124,7 @@ - + diff --git a/Lawo.EmberPlusSharp/Model/CollectionNode.cs b/Lawo.EmberPlusSharp/Model/CollectionNode.cs index 5005829f..71f3ac25 100644 --- a/Lawo.EmberPlusSharp/Model/CollectionNode.cs +++ b/Lawo.EmberPlusSharp/Model/CollectionNode.cs @@ -61,17 +61,17 @@ internal sealed override Element ReadNewChildContents( } [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", Justification = "Method is not public, CA bug?")] - internal sealed override bool ChangeOnlineStatus(IElement child) + internal sealed override bool ChangeVisibility(Element child) { - base.ChangeOnlineStatus(child); + base.ChangeVisibility(child); - if (child.IsOnline) + if (child.RetrieveDetails) { - this.children.Add((TElement)child); + this.children.Add((TElement)(IElement)child); } else { - this.children.Remove((TElement)child); + this.children.Remove((TElement)(IElement)child); } return true; diff --git a/Lawo.EmberPlusSharp/Model/DynamicFieldNode.cs b/Lawo.EmberPlusSharp/Model/DynamicFieldNode.cs index e8936f54..fac38927 100644 --- a/Lawo.EmberPlusSharp/Model/DynamicFieldNode.cs +++ b/Lawo.EmberPlusSharp/Model/DynamicFieldNode.cs @@ -33,9 +33,9 @@ public ReadOnlyObservableCollection DynamicChildren //////////////////////////////////////////////////////////////////////////////////////////////////////////////// - internal sealed override bool ChangeOnlineStatus(IElement child) + internal sealed override bool ChangeVisibility(Element child) { - return DynamicNodeHelper.ChangeOnlineStatus(base.ChangeOnlineStatus, this.dynamicChildren, child); + return DynamicNodeHelper.ChangeVisibility(base.ChangeVisibility, this.dynamicChildren, child); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/Lawo.EmberPlusSharp/Model/DynamicNodeHelper.cs b/Lawo.EmberPlusSharp/Model/DynamicNodeHelper.cs index 229d9258..93d66697 100644 --- a/Lawo.EmberPlusSharp/Model/DynamicNodeHelper.cs +++ b/Lawo.EmberPlusSharp/Model/DynamicNodeHelper.cs @@ -30,12 +30,12 @@ internal static Element ReadDynamicChildContents( } } - internal static bool ChangeOnlineStatus( - Func baseImpl, ObservableCollection dynamicChildren, IElement child) + internal static bool ChangeVisibility( + Func baseImpl, ObservableCollection dynamicChildren, Element child) { if (!baseImpl(child)) { - if (child.IsOnline) + if (child.RetrieveDetails) { dynamicChildren.Add(child); } diff --git a/Lawo.EmberPlusSharp/Model/DynamicRoot.cs b/Lawo.EmberPlusSharp/Model/DynamicRoot.cs index 79373439..3704bb44 100644 --- a/Lawo.EmberPlusSharp/Model/DynamicRoot.cs +++ b/Lawo.EmberPlusSharp/Model/DynamicRoot.cs @@ -41,9 +41,9 @@ internal sealed override Element ReadNewDynamicChildContents( return DynamicNodeHelper.ReadDynamicChildContents(reader, actualType, context, out childRetrievalState); } - internal sealed override bool ChangeOnlineStatus(IElement child) + internal sealed override bool ChangeVisibility(Element child) { - return DynamicNodeHelper.ChangeOnlineStatus(base.ChangeOnlineStatus, this.dynamicChildren, child); + return DynamicNodeHelper.ChangeVisibility(base.ChangeVisibility, this.dynamicChildren, child); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/Lawo.EmberPlusSharp/Model/Element.cs b/Lawo.EmberPlusSharp/Model/Element.cs index 2016d689..813d23b0 100644 --- a/Lawo.EmberPlusSharp/Model/Element.cs +++ b/Lawo.EmberPlusSharp/Model/Element.cs @@ -27,6 +27,7 @@ public abstract class Element : NotifyPropertyChanged, IElement private string identifier; private string description; private bool isOnline = true; + private object tag; private bool hasChanges; //////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -75,20 +76,24 @@ internal set { // 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. - if (this.IsOnlineChangeStatus == IsOnlineChangeStatus.Unchanged) + if (this.RetrieveDetailsChangeStatus == RetrieveDetailsChangeStatus.Unchanged) { - this.IsOnlineChangeStatus = IsOnlineChangeStatus.Changed; + this.RetrieveDetailsChangeStatus = RetrieveDetailsChangeStatus.Changed; } - else if (this.IsOnlineChangeStatus == IsOnlineChangeStatus.Changed) + else if (this.RetrieveDetailsChangeStatus == RetrieveDetailsChangeStatus.Changed) { - this.IsOnlineChangeStatus = IsOnlineChangeStatus.Unchanged; + this.RetrieveDetailsChangeStatus = RetrieveDetailsChangeStatus.Unchanged; } } } } /// - public object Tag { get; set; } + public object Tag + { + get { return this.tag; } + set { this.SetValue(ref this.tag, value); } + } /// public string GetPath() @@ -115,8 +120,6 @@ internal int[] NumberPath get { return this.numberPath; } } - internal IsOnlineChangeStatus IsOnlineChangeStatus { get; set; } - internal bool HasChanges { get @@ -138,6 +141,13 @@ internal bool HasChanges } } + internal virtual bool RetrieveDetails + { + get { return this.IsOnline; } + } + + internal RetrieveDetailsChangeStatus RetrieveDetailsChangeStatus { get; set; } + internal virtual RetrievalState RetrievalState { get { return RetrievalState.Complete; } diff --git a/Lawo.EmberPlusSharp/Model/ElementWithSchemas.cs b/Lawo.EmberPlusSharp/Model/ElementWithSchemas.cs index 93a851bf..f98c3da5 100644 --- a/Lawo.EmberPlusSharp/Model/ElementWithSchemas.cs +++ b/Lawo.EmberPlusSharp/Model/ElementWithSchemas.cs @@ -20,7 +20,7 @@ public abstract class ElementWithSchemas : Element, where TMostDerived : ElementWithSchemas { /// See for more information. - /// This field and its sibling are modified by the following + /// This field and its sibling are modified by the following /// methods, which are directly or indirectly called from /// : /// @@ -40,8 +40,8 @@ public abstract class ElementWithSchemas : Element, /// are changed at once in a large tree. /// /// - private RetrievalState offlineRetrievalState = RetrievalState.Complete; - private RetrievalState onlineRetrievalState; + private RetrievalState noDetailsRetrievalState = RetrievalState.Complete; + private RetrievalState detailsRetrievalState; private IReadOnlyList schemaIdentifiers; @@ -56,38 +56,38 @@ public IReadOnlyList SchemaIdentifiers //////////////////////////////////////////////////////////////////////////////////////////////////////////////// - internal ElementWithSchemas(RetrievalState onlineRetrievalState) + internal ElementWithSchemas(RetrievalState detailsRetrievalState) { - this.onlineRetrievalState = onlineRetrievalState; + this.detailsRetrievalState = detailsRetrievalState; } /// Gets or sets the retrieval state. /// This implementation has nothing to do with schemas. However, it so happens that this member has the /// same behavior for all subclasses (parameters, nodes and matrices). If this fact ever changes, it probably /// makes sense to move this member to its own base class (named e.g. RequestedElement). - internal override RetrievalState RetrievalState + internal sealed override RetrievalState RetrievalState { get { - return this.IsOnline ? this.onlineRetrievalState : this.offlineRetrievalState; + return this.RetrieveDetails ? this.detailsRetrievalState : this.noDetailsRetrievalState; } set { - if (this.IsOnline) + if (this.RetrieveDetails) { - this.onlineRetrievalState = value; + this.detailsRetrievalState = value; } else { - this.offlineRetrievalState = value; + this.noDetailsRetrievalState = value; } } } internal override RetrievalState UpdateRetrievalState(bool throwForMissingRequiredChildren) { - if (!this.IsOnline || (this.RetrievalState.Equals(RetrievalState.Complete) && + if (!this.RetrieveDetails || (this.RetrievalState.Equals(RetrievalState.Complete) && this.AreRequiredChildrenAvailable(throwForMissingRequiredChildren))) { this.RetrievalState = base.UpdateRetrievalState(throwForMissingRequiredChildren); diff --git a/Lawo.EmberPlusSharp/Model/FieldNode.cs b/Lawo.EmberPlusSharp/Model/FieldNode.cs index b60bb165..3c62fb84 100644 --- a/Lawo.EmberPlusSharp/Model/FieldNode.cs +++ b/Lawo.EmberPlusSharp/Model/FieldNode.cs @@ -57,15 +57,15 @@ internal virtual Element ReadNewDynamicChildContents( } [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", Justification = "Method is not public, CA bug?")] - internal override bool ChangeOnlineStatus(IElement child) + internal override bool ChangeVisibility(Element child) { - base.ChangeOnlineStatus(child); + base.ChangeVisibility(child); MetaElement metaChild; var result = MetaChildren.TryGetValue(child.Identifier, out metaChild); if (result) { - metaChild.ChangeOnlineStatus(this, child); + metaChild.ChangeVisibility(this, child); } return result; diff --git a/Lawo.EmberPlusSharp/Model/MetaElement.cs b/Lawo.EmberPlusSharp/Model/MetaElement.cs index ecd9d1dd..626442e8 100644 --- a/Lawo.EmberPlusSharp/Model/MetaElement.cs +++ b/Lawo.EmberPlusSharp/Model/MetaElement.cs @@ -46,7 +46,7 @@ internal abstract Element ReadContents( internal abstract bool IsAvailable(IParent parent, bool throwIfMissing); - internal abstract void ChangeOnlineStatus(IParent parent, IElement element); + internal abstract void ChangeVisibility(IParent parent, Element element); //////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/Lawo.EmberPlusSharp/Model/MetaElement1.cs b/Lawo.EmberPlusSharp/Model/MetaElement1.cs index 1fd3006f..ddad1f3b 100644 --- a/Lawo.EmberPlusSharp/Model/MetaElement1.cs +++ b/Lawo.EmberPlusSharp/Model/MetaElement1.cs @@ -66,16 +66,16 @@ internal sealed override bool IsAvailable(IParent parent, bool throwIfMissing) } [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", Justification = "Method is not public, CA bug?")] - internal sealed override void ChangeOnlineStatus(IParent parent, IElement element) + internal sealed override void ChangeVisibility(IParent parent, Element element) { - if (!this.IsOptional && !element.IsOnline) + if (!this.IsOptional && !element.RetrieveDetails) { const string Format = "The required property {0}.{1} in the node with the path {2} has been set offline by the provider."; throw CreateRequiredPropertyException(parent, Format); } - this.set((TMostDerived)parent, (TProperty)(element.IsOnline ? element : null)); + this.set((TMostDerived)parent, (TProperty)(element.RetrieveDetails ? element : null)); parent.OnPropertyChanged(new PropertyChangedEventArgs(this.Property.Name)); } diff --git a/Lawo.EmberPlusSharp/Model/Node.cs b/Lawo.EmberPlusSharp/Model/Node.cs index 956214c9..106c77da 100644 --- a/Lawo.EmberPlusSharp/Model/Node.cs +++ b/Lawo.EmberPlusSharp/Model/Node.cs @@ -71,9 +71,9 @@ internal virtual bool GetIsRoot() } [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", Justification = "Method is not public, CA bug?")] - internal override bool ChangeOnlineStatus(IElement child) + internal override bool ChangeVisibility(Element child) { - if (child.IsOnline) + if (child.RetrieveDetails) { this.observableChildren.Add(child); } @@ -82,7 +82,7 @@ internal override bool ChangeOnlineStatus(IElement child) this.observableChildren.Remove(child); } - return base.ChangeOnlineStatus(child); + return base.ChangeVisibility(child); } internal sealed override RetrievalState ReadContents(EmberReader reader, ElementType actualType) diff --git a/Lawo.EmberPlusSharp/Model/NodeBase.cs b/Lawo.EmberPlusSharp/Model/NodeBase.cs index 2f112d76..89e66d31 100644 --- a/Lawo.EmberPlusSharp/Model/NodeBase.cs +++ b/Lawo.EmberPlusSharp/Model/NodeBase.cs @@ -167,10 +167,10 @@ internal virtual bool ReadChildrenCore(EmberReader reader) return isEmpty; } - /// Changes the online status of . - /// The child to change the online status for. - /// true if the online status has been changed; otherwise, false. - internal virtual bool ChangeOnlineStatus(IElement child) + /// Changes the visibility of . + /// The child to change the visibility for. + /// true if the visibility has been changed; otherwise, false. + internal virtual bool ChangeVisibility(Element child) { return false; } @@ -211,7 +211,7 @@ internal sealed override RetrievalState ReadQualifiedChild( internal sealed override RetrievalState UpdateRetrievalState(bool throwForMissingRequiredChildren) { - if (!this.IsOnline || (this.children.Count == 0)) + if (!this.RetrieveDetails || (this.children.Count == 0)) { return base.UpdateRetrievalState(throwForMissingRequiredChildren); } @@ -226,12 +226,13 @@ internal sealed override RetrievalState UpdateRetrievalState(bool throwForMissin var childRetrievalState = child.UpdateRetrievalState(throwForMissingRequiredChildren); accumulatedChildRetrievalState &= childRetrievalState; - if (child.IsOnlineChangeStatus != IsOnlineChangeStatus.Unchanged) + if (child.RetrieveDetailsChangeStatus != RetrieveDetailsChangeStatus.Unchanged) { - if ((child.IsOnline && childRetrievalState.Equals(RetrievalState.Verified)) || !child.IsOnline) + if ((child.RetrieveDetails && childRetrievalState.Equals(RetrievalState.Verified)) || + !child.RetrieveDetails) { - child.IsOnlineChangeStatus = IsOnlineChangeStatus.Unchanged; - this.ChangeOnlineStatus(child); + child.RetrieveDetailsChangeStatus = RetrieveDetailsChangeStatus.Unchanged; + this.ChangeVisibility(child); } } } diff --git a/Lawo.EmberPlusSharp/Model/ParameterBase.cs b/Lawo.EmberPlusSharp/Model/ParameterBase.cs index 360981b2..1f5c8672 100644 --- a/Lawo.EmberPlusSharp/Model/ParameterBase.cs +++ b/Lawo.EmberPlusSharp/Model/ParameterBase.cs @@ -279,8 +279,8 @@ internal override RetrievalState ReadContents(EmberReader reader, ElementType ac break; case GlowParameterContents.IsOnline.OuterNumber: this.IsOnline = reader.AssertAndReadContentsAsBoolean(); - var send = (this.IsOnlineChangeStatus == IsOnlineChangeStatus.Changed) && - this.IsOnline && this.StreamIdentifier.HasValue; + var send = (this.RetrieveDetailsChangeStatus == RetrieveDetailsChangeStatus.Changed) && + this.RetrieveDetails && this.StreamIdentifier.HasValue; this.RetrievalState &= send ? RetrievalState.None : RetrievalState.Complete; break; case GlowParameterContents.Formula.OuterNumber: @@ -359,7 +359,7 @@ private int? StreamIdentifier { this.streamIdentifier = value; - if (value.HasValue && this.IsOnline) + if (value.HasValue && this.RetrieveDetails) { this.RetrievalState = RetrievalState.None; } @@ -429,7 +429,7 @@ private void SetFinalTytpe(ParameterType? valueType, ParameterType? enumType, Pa } else { - if (this.IsOnline) + if (this.RetrieveDetails) { const string Format = "No enumeration, enumMap, value or type field is available for the parameter with the path {0}."; diff --git a/Lawo.EmberPlusSharp/Model/IsOnlineChangeStatus.cs b/Lawo.EmberPlusSharp/Model/RetrieveDetailsChangeStatus.cs similarity index 54% rename from Lawo.EmberPlusSharp/Model/IsOnlineChangeStatus.cs rename to Lawo.EmberPlusSharp/Model/RetrieveDetailsChangeStatus.cs index 288b1b6e..ac56463d 100644 --- a/Lawo.EmberPlusSharp/Model/IsOnlineChangeStatus.cs +++ b/Lawo.EmberPlusSharp/Model/RetrieveDetailsChangeStatus.cs @@ -6,18 +6,18 @@ namespace Lawo.EmberPlusSharp.Model { - internal enum IsOnlineChangeStatus + internal enum RetrieveDetailsChangeStatus { - /// has the value set during initialization or first read operation. + /// has the value set during initialization or first read operation. /// Initialized, - /// has not been changed since - /// has been reset. + /// has not been changed since + /// has been reset. Unchanged, - /// has been changed since - /// has been reset. + /// has been changed since + /// has been reset. Changed } } diff --git a/Lawo.EmberPlusSharp/Model/ShadowNode.cs b/Lawo.EmberPlusSharp/Model/ShadowNode.cs index 1aaa5872..3c477a4e 100644 --- a/Lawo.EmberPlusSharp/Model/ShadowNode.cs +++ b/Lawo.EmberPlusSharp/Model/ShadowNode.cs @@ -16,7 +16,7 @@ internal sealed class ShadowNode : NodeBase { internal ShadowNode() { - this.IsOnlineChangeStatus = IsOnlineChangeStatus.Unchanged; + this.RetrieveDetailsChangeStatus = RetrieveDetailsChangeStatus.Unchanged; } [SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", Justification = "Official Glow name.")]