Skip to content

Commit

Permalink
Make StreamIdentifier and StreamDescription private
Browse files Browse the repository at this point in the history
References #8
  • Loading branch information
andreashuber-lawo committed Jan 11, 2016
1 parent 4c12138 commit e459c77
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 36 deletions.
4 changes: 2 additions & 2 deletions Lawo.EmberPlusSharp/Glow/GlowLogConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -270,11 +270,11 @@ private static object GetValue(IElement element, string name)
case "Type":
return LowerFirst(((IParameter)element).Type.ToString());
case "StreamIdentifier":
return ((IParameter)element).StreamIdentifier;
return ((IStreamedParameter)element).StreamIdentifier;
case "EnumMap":
return ((IParameter)element).EnumMap;
case "StreamDescriptor":
return ((IParameter)element).StreamDescriptor;
return ((IStreamedParameter)element).StreamDescriptor;
case "Arguments":
return ((IFunction)element).Arguments;
case "Result":
Expand Down
6 changes: 0 additions & 6 deletions Lawo.EmberPlusSharp/Model/IParameter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,11 @@ public interface IParameter : IElementWithSchemas
/// where <see cref="IElement.IsOnline"/> equals <c>false</c>.</exception>
ParameterType Type { get; }

/// <summary>Gets <b>streamIdentifier</b> (not yet supported).</summary>
int? StreamIdentifier { get; }

/// <summary>Gets <b>enumMap</b>.</summary>
/// <remarks>The returned collection contains the entries of either the <b>enumeration</b> field or the
/// <b>enumMap</b> field.
/// If the provider sets both fields, the collection contains the entries of the field that appeared last in the
/// EmBER-encoded data.</remarks>
IReadOnlyList<KeyValuePair<string, int>> EnumMap { get; }

/// <summary>Gets <b>streamDescriptor</b>.</summary>
StreamDescription? StreamDescriptor { get; }
}
}
4 changes: 4 additions & 0 deletions Lawo.EmberPlusSharp/Model/IStreamedParameter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ namespace Lawo.EmberPlusSharp.Model
{
internal interface IStreamedParameter : IParameter
{
int? StreamIdentifier { get; }

StreamDescription? StreamDescriptor { get; }

void SetProviderValue(object value);
}
}
58 changes: 33 additions & 25 deletions Lawo.EmberPlusSharp/Model/ParameterBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public abstract class ParameterBase<TMostDerived, TValue> : ElementWithSchemas<T
private TValue defaultValue;
private ParameterType? type;
private int? streamIdentifier;
private StreamDescription? streamDescriptor;

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

Expand Down Expand Up @@ -61,30 +60,6 @@ public ParameterType Type
private set { this.SetValue(ref this.type, value); }
}

/// <inheritdoc/>
public int? StreamIdentifier
{
get
{
return this.streamIdentifier;
}

private set
{
if (this.SetValue(ref this.streamIdentifier, value) && value.HasValue && this.IsOnline)
{
this.RequestState = RequestState.None;
}
}
}

/// <inheritdoc/>
public StreamDescription? StreamDescriptor
{
get { return this.streamDescriptor; }
private set { this.SetValue(ref this.streamDescriptor, value); }
}

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

[SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes", Justification = "Required property is provided by subclasses.")]
Expand Down Expand Up @@ -129,6 +104,16 @@ IReadOnlyList<KeyValuePair<string, int>> IParameter.EnumMap
get { return this.EnumMapCore; }
}

int? IStreamedParameter.StreamIdentifier
{
get { return this.StreamIdentifier; }
}

StreamDescription? IStreamedParameter.StreamDescriptor
{
get { return this.StreamDescriptor; }
}

void IStreamedParameter.SetProviderValue(object value)
{
this.SetProviderValue(AssertValueType(value));
Expand Down Expand Up @@ -361,6 +346,29 @@ internal sealed override void WriteChanges(EmberWriter writer, IInvocationCollec

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

private int? StreamIdentifier
{
get
{
return this.streamIdentifier;
}

set
{
if (this.streamIdentifier != value)
{
this.streamIdentifier = value;

if (value.HasValue && this.IsOnline)
{
this.RequestState = RequestState.None;
}
}
}
}

private StreamDescription? StreamDescriptor { get; set; }

private void SetProviderValue(TValue value)
{
if (!this.HasChanges)
Expand Down
3 changes: 0 additions & 3 deletions Lawo.EmberPlusSharpTest/Model/ConsumerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -414,9 +414,6 @@ await MonitorConnection(
AssertAreEqual(defaultValue, (IParameter e) => e.DefaultValue, e1, e2, e3, e4);
AssertAreEqual(ParameterType.Integer, (IParameter e) => e.Type, e1, e2);
AssertAreEqual(ParameterType.Enum, (IParameter e) => e.Type, e3, e4);
AssertAreEqual(streamIdentifier, (IParameter e) => e.StreamIdentifier, e1, e2, e3, e4);
AssertAreEqual(streamFormat, (IParameter e) => e.StreamDescriptor.Value.Format, e1, e2, e3, e4);
AssertAreEqual(streamOffset, (IParameter e) => e.StreamDescriptor.Value.Offset, e1, e2, e3, e4);
AssertAreEqual(formula, (IParameter e) => e.Formula, e2);
AssertEnumMapEquality(enumStrings, new[] { 0, 1, 3, 4 }, e3.EnumMap);
AssertEnumMapEquality(enumStrings, enumValues, ((IParameter)e4).EnumMap);
Expand Down

0 comments on commit e459c77

Please sign in to comment.