From e45bf107907c4a308696670e021961122f806acd Mon Sep 17 00:00:00 2001 From: andreashuber-lawo Date: Wed, 6 Jan 2016 12:11:09 +0100 Subject: [PATCH] Eliminate SetRequestState References #8 --- Lawo.EmberPlusSharp/Model/Element.cs | 11 ++++++----- .../Model/ElementWithSchemas.cs | 18 ++++-------------- Lawo.EmberPlusSharp/Model/NodeBase.cs | 7 ++++++- 3 files changed, 16 insertions(+), 20 deletions(-) diff --git a/Lawo.EmberPlusSharp/Model/Element.cs b/Lawo.EmberPlusSharp/Model/Element.cs index 13184ceb..6b85a586 100644 --- a/Lawo.EmberPlusSharp/Model/Element.cs +++ b/Lawo.EmberPlusSharp/Model/Element.cs @@ -143,6 +143,12 @@ internal bool HasChanges } } + internal virtual RequestState RequestState + { + get { return RequestState.Complete; } + set { } // Intentionally empty + } + internal void SetContext(Context context) { this.parent = context.Parent; @@ -193,11 +199,6 @@ internal void SetConsumerValue(ref T field, T newValue, [CallerMemberName] st } } - internal virtual void SetRequestState(bool isEmpty, ref RequestState newRequestState) - { - newRequestState = RequestState.Complete; - } - internal abstract RequestState ReadContents(EmberReader reader, ElementType actualType); /// Recursively reads the children of an element as they appear in the message payload and returns diff --git a/Lawo.EmberPlusSharp/Model/ElementWithSchemas.cs b/Lawo.EmberPlusSharp/Model/ElementWithSchemas.cs index 152d387a..6d2c4f8a 100644 --- a/Lawo.EmberPlusSharp/Model/ElementWithSchemas.cs +++ b/Lawo.EmberPlusSharp/Model/ElementWithSchemas.cs @@ -62,10 +62,10 @@ internal ElementWithSchemas(RequestState onlineRequestState) } /// Gets or sets the request state. - /// This property (along with its backing fields) has nothing to do with schemas. However, it so - /// happens that all subclasses (parameters, nodes and matrices) need this member. If this fact ever changes, it - /// probably makes sense to move this member to its own base class (named e.g. RequestedElement). - internal RequestState RequestState + /// 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 RequestState RequestState { get { @@ -85,16 +85,6 @@ internal RequestState RequestState } } - internal sealed override void SetRequestState(bool isEmpty, ref RequestState newRequestState) - { - if (isEmpty) - { - base.SetRequestState(isEmpty, ref newRequestState); - } - - this.RequestState = newRequestState; - } - internal override RequestState UpdateRequestState(bool throwForMissingRequiredChildren) { if (!this.IsOnline || (this.RequestState.Equals(RequestState.Complete) && diff --git a/Lawo.EmberPlusSharp/Model/NodeBase.cs b/Lawo.EmberPlusSharp/Model/NodeBase.cs index 2eb26926..fbda0e3d 100644 --- a/Lawo.EmberPlusSharp/Model/NodeBase.cs +++ b/Lawo.EmberPlusSharp/Model/NodeBase.cs @@ -299,7 +299,12 @@ private void ReadChild(EmberReader reader, ElementType actualType, int number) if (child != null) { - child.SetRequestState(isEmpty, ref childRequestState); + if (isEmpty) + { + childRequestState = RequestState.Complete; + } + + child.RequestState = childRequestState; } this.RequestState =