Skip to content

Commit

Permalink
Fix a bug that prevented streamed changes for read-only parameters
Browse files Browse the repository at this point in the history
References #8
  • Loading branch information
andreashuber-lawo committed Jan 9, 2016
1 parent 45e2313 commit f612f07
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
1 change: 1 addition & 0 deletions Lawo.EmberPlusSharp/Model/IStreamedParameter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ namespace Lawo.EmberPlusSharp.Model
{
internal interface IStreamedParameter : IParameter
{
void SetProviderValue(object value);
}
}
19 changes: 14 additions & 5 deletions Lawo.EmberPlusSharp/Model/ParameterBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ IReadOnlyList<KeyValuePair<string, int>> IParameter.EnumMap
get { return this.EnumMapCore; }
}

void IStreamedParameter.SetProviderValue(object value)
{
this.SetProviderValue(AssertValueType(value));
}

internal ParameterBase() : base(RequestState.Complete)
{
}
Expand Down Expand Up @@ -266,11 +271,7 @@ internal override RequestState ReadContents(EmberReader reader, ElementType actu
this.Description = reader.AssertAndReadContentsAsString();
break;
case GlowParameterContents.Value.OuterNumber:
if (!this.HasChanges)
{
this.SetValue(ref this.theValue, this.ReadValue(reader, out valueType), "Value");
}

this.SetProviderValue(this.ReadValue(reader, out valueType));
break;
case GlowParameterContents.Minimum.OuterNumber:
this.SetMinimum(this.ReadValue(reader, out dummyType));
Expand Down Expand Up @@ -360,6 +361,14 @@ internal sealed override void WriteChanges(EmberWriter writer, IInvocationCollec

////////////////////////////////////////////////////////////////////////////////////////////////////////////////

private void SetProviderValue(TValue value)
{
if (!this.HasChanges)
{
this.SetValue(ref this.theValue, value, "Value");
}
}

private List<KeyValuePair<string, int>> ReadEnumMap(EmberReader reader)
{
reader.AssertInnerNumber(GlowStringIntegerCollection.InnerNumber);
Expand Down
2 changes: 1 addition & 1 deletion Lawo.EmberPlusSharp/Model/Root.cs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ private static void ReadStreamEntry(

try
{
parameter.Value = value;
parameter.SetProviderValue(value);
}
catch (ArgumentException ex)
{
Expand Down
4 changes: 2 additions & 2 deletions Lawo.EmberPlusSharpTest/Model/ConsumerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -870,9 +870,9 @@ public void StreamTest()
};

AsyncPump.Run(() => TestWithRobot<StreamRoot>(
consumer =>
async consumer =>
{
return Task.FromResult(false);
await Task.Delay(1000);
},
false,
"StreamLog.xml",
Expand Down

0 comments on commit f612f07

Please sign in to comment.