Skip to content

Commit

Permalink
Have WriteChanges update the RetrievalState
Browse files Browse the repository at this point in the history
References #21
  • Loading branch information
andreashuber-lawo committed Apr 26, 2016
1 parent 7fe7989 commit 9c8b7db
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 9 deletions.
1 change: 1 addition & 0 deletions Lawo.EmberPlusSharp/Model/Consumer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ public async Task SendAsync()
}

await this.client.SendMessageAsync(this.emberDataMessage, stream.ToArray());
await this.RetrieveChildrenAsync();
}
}

Expand Down
2 changes: 1 addition & 1 deletion Lawo.EmberPlusSharp/Model/Element.cs
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ internal virtual bool WriteRequest(EmberWriter writer, IStreamedParameterCollect
return false;
}

internal abstract void WriteChanges(EmberWriter writer, IInvocationCollection pendingInvocations);
internal abstract RetrievalState WriteChanges(EmberWriter writer, IInvocationCollection pendingInvocations);

internal virtual void SetComplete()
{
Expand Down
5 changes: 4 additions & 1 deletion Lawo.EmberPlusSharp/Model/FunctionBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ internal override RetrievalState ReadContents(EmberReader reader, ElementType ac
return RetrievalState.Complete;
}

internal sealed override void WriteChanges(EmberWriter writer, IInvocationCollection pendingInvocations)
internal sealed override RetrievalState WriteChanges(
EmberWriter writer, IInvocationCollection pendingInvocations)
{
if (this.HasChanges)
{
Expand All @@ -120,6 +121,8 @@ internal sealed override void WriteChanges(EmberWriter writer, IInvocationCollec
writer.WriteEndContainer();
this.HasChanges = false;
}

return RetrievalState.Complete;
}

internal abstract KeyValuePair<string, ParameterType>[] ReadTupleDescription(
Expand Down
5 changes: 4 additions & 1 deletion Lawo.EmberPlusSharp/Model/Matrix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,8 @@ internal override RetrievalState ReadContents(EmberReader reader, ElementType ac
return this.RetrievalState;
}

internal sealed override void WriteChanges(EmberWriter writer, IInvocationCollection pendingInvocations)
internal sealed override RetrievalState WriteChanges(
EmberWriter writer, IInvocationCollection pendingInvocations)
{
////if (this.HasChanges)
////{
Expand All @@ -212,6 +213,8 @@ internal sealed override void WriteChanges(EmberWriter writer, IInvocationCollec
//// writer.WriteEndContainer();
//// this.HasChanges = false;
////}

return this.RetrievalState;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down
5 changes: 4 additions & 1 deletion Lawo.EmberPlusSharp/Model/Node.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,16 @@ internal sealed override RetrievalState ReadContents(EmberReader reader, Element
return this.RetrievalState;
}

internal override void WriteChanges(EmberWriter writer, IInvocationCollection pendingInvocations)
internal override RetrievalState WriteChanges(
EmberWriter writer, IInvocationCollection pendingInvocations)
{
if (this.HasChanges)
{
this.WriteChangesCollection(writer, pendingInvocations);
this.HasChanges = false;
}

return this.RetrievalState;
}

internal sealed override IElement GetElement(string[] pathElements, int index)
Expand Down
14 changes: 12 additions & 2 deletions Lawo.EmberPlusSharp/Model/NodeBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,19 @@ internal bool WriteCommandCollection(EmberWriter writer, IStreamedParameterColle

internal void WriteChangesCollection(EmberWriter writer, IInvocationCollection pendingInvocations)
{
foreach (var child in this.children.Values)
if (this.children.Count == 0)
{
if (this.RetrieveDetails && (this.RetrieveDetailsChangeStatus == RetrieveDetailsChangeStatus.Changed))
{
this.WriteCommandCollection(writer, GlowCommandNumber.GetDirectory, RetrievalState.RequestSent);
}
}
else
{
child.WriteChanges(writer, pendingInvocations);
foreach (var child in this.children.Values)
{
this.RetrievalState &= child.WriteChanges(writer, pendingInvocations);
}
}
}

Expand Down
5 changes: 4 additions & 1 deletion Lawo.EmberPlusSharp/Model/ParameterBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,8 @@ internal override RetrievalState ReadContents(EmberReader reader, ElementType ac
return this.RetrievalState;
}

internal sealed override void WriteChanges(EmberWriter writer, IInvocationCollection pendingInvocations)
internal sealed override RetrievalState WriteChanges(
EmberWriter writer, IInvocationCollection pendingInvocations)
{
if (this.HasChanges)
{
Expand All @@ -342,6 +343,8 @@ internal sealed override void WriteChanges(EmberWriter writer, IInvocationCollec
writer.WriteEndContainer();
this.HasChanges = false;
}

return this.RetrievalState;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down
5 changes: 4 additions & 1 deletion Lawo.EmberPlusSharp/Model/Root.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ internal sealed override bool WriteRequest(EmberWriter writer, IStreamedParamete
}

[SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", Justification = "Method is not public, CA bug?")]
internal sealed override void WriteChanges(EmberWriter writer, IInvocationCollection pendingInvocations)
internal sealed override RetrievalState WriteChanges(
EmberWriter writer, IInvocationCollection pendingInvocations)
{
if (this.HasChanges)
{
Expand All @@ -151,6 +152,8 @@ internal sealed override void WriteChanges(EmberWriter writer, IInvocationCollec
writer.WriteEndContainer();
this.HasChanges = false;
}

return this.RetrievalState;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down
4 changes: 3 additions & 1 deletion Lawo.EmberPlusSharp/Model/ShadowNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ internal sealed override RetrievalState ReadContents(EmberReader reader, Element
throw new ModelException("Unexpected contents for intermediate node in basePath.");
}

internal sealed override void WriteChanges(EmberWriter writer, IInvocationCollection pendingInvocations)
internal sealed override RetrievalState WriteChanges(
EmberWriter writer, IInvocationCollection pendingInvocations)
{
this.HasChanges = false;
return this.RetrievalState;
}
}
}

0 comments on commit 9c8b7db

Please sign in to comment.