From e459c77f09f9dee59f520212b62b0e0ba1f5b3c2 Mon Sep 17 00:00:00 2001 From: andreashuber-lawo Date: Mon, 11 Jan 2016 15:42:01 +0100 Subject: [PATCH] Make StreamIdentifier and StreamDescription private References #8 --- Lawo.EmberPlusSharp/Glow/GlowLogConverter.cs | 4 +- Lawo.EmberPlusSharp/Model/IParameter.cs | 6 -- .../Model/IStreamedParameter.cs | 4 ++ Lawo.EmberPlusSharp/Model/ParameterBase.cs | 58 +++++++++++-------- Lawo.EmberPlusSharpTest/Model/ConsumerTest.cs | 3 - 5 files changed, 39 insertions(+), 36 deletions(-) diff --git a/Lawo.EmberPlusSharp/Glow/GlowLogConverter.cs b/Lawo.EmberPlusSharp/Glow/GlowLogConverter.cs index ab3a3688..9c8901da 100644 --- a/Lawo.EmberPlusSharp/Glow/GlowLogConverter.cs +++ b/Lawo.EmberPlusSharp/Glow/GlowLogConverter.cs @@ -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": diff --git a/Lawo.EmberPlusSharp/Model/IParameter.cs b/Lawo.EmberPlusSharp/Model/IParameter.cs index 712da28c..e17d5393 100644 --- a/Lawo.EmberPlusSharp/Model/IParameter.cs +++ b/Lawo.EmberPlusSharp/Model/IParameter.cs @@ -52,17 +52,11 @@ public interface IParameter : IElementWithSchemas /// where equals false. ParameterType Type { get; } - /// Gets streamIdentifier (not yet supported). - int? StreamIdentifier { get; } - /// Gets enumMap. /// The returned collection contains the entries of either the enumeration field or the /// enumMap field. /// If the provider sets both fields, the collection contains the entries of the field that appeared last in the /// EmBER-encoded data. IReadOnlyList> EnumMap { get; } - - /// Gets streamDescriptor. - StreamDescription? StreamDescriptor { get; } } } diff --git a/Lawo.EmberPlusSharp/Model/IStreamedParameter.cs b/Lawo.EmberPlusSharp/Model/IStreamedParameter.cs index 0471aa60..2dce8494 100644 --- a/Lawo.EmberPlusSharp/Model/IStreamedParameter.cs +++ b/Lawo.EmberPlusSharp/Model/IStreamedParameter.cs @@ -8,6 +8,10 @@ namespace Lawo.EmberPlusSharp.Model { internal interface IStreamedParameter : IParameter { + int? StreamIdentifier { get; } + + StreamDescription? StreamDescriptor { get; } + void SetProviderValue(object value); } } diff --git a/Lawo.EmberPlusSharp/Model/ParameterBase.cs b/Lawo.EmberPlusSharp/Model/ParameterBase.cs index 2cc97fa5..139fe077 100644 --- a/Lawo.EmberPlusSharp/Model/ParameterBase.cs +++ b/Lawo.EmberPlusSharp/Model/ParameterBase.cs @@ -29,7 +29,6 @@ public abstract class ParameterBase : ElementWithSchemas - public int? StreamIdentifier - { - get - { - return this.streamIdentifier; - } - - private set - { - if (this.SetValue(ref this.streamIdentifier, value) && value.HasValue && this.IsOnline) - { - this.RequestState = RequestState.None; - } - } - } - - /// - 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.")] @@ -129,6 +104,16 @@ IReadOnlyList> 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)); @@ -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) diff --git a/Lawo.EmberPlusSharpTest/Model/ConsumerTest.cs b/Lawo.EmberPlusSharpTest/Model/ConsumerTest.cs index e7f702e3..a51fa72b 100644 --- a/Lawo.EmberPlusSharpTest/Model/ConsumerTest.cs +++ b/Lawo.EmberPlusSharpTest/Model/ConsumerTest.cs @@ -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);