Skip to content

Commit

Permalink
Closes #15
Browse files Browse the repository at this point in the history
  • Loading branch information
andreashuber-lawo committed Nov 24, 2015
1 parent 2cd3930 commit a00c2af
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
2 changes: 2 additions & 0 deletions Lawo.EmberPlusSharp/Model/IParameter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ public interface IParameter : IElementWithSchemas
object DefaultValue { get; }

/// <summary>Gets <b>type</b>.</summary>
/// <exception cref="InvalidOperationException">The type is not available. This can only happen for a parameter
/// where <see cref="IElement.IsOnline"/> equals <c>false</c>.</exception>
ParameterType Type { get; }

/// <summary>Gets <b>streamIdentifier</b> (not yet supported).</summary>
Expand Down
17 changes: 11 additions & 6 deletions Lawo.EmberPlusSharp/Model/ParameterBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -375,14 +375,19 @@ private void SetFinalTytpe(ParameterType? valueType, ParameterType? enumType, Pa
var finalType =
this.type ?? (typeType == ParameterType.Trigger ? typeType : null) ?? enumType ?? valueType ?? typeType;

if (!finalType.HasValue)
if (finalType.HasValue)
{
const string Format =
"No enumeration, enumMap, value or type field is available for the parameter with the path {0}.";
throw new ModelException(string.Format(CultureInfo.InvariantCulture, Format, this.GetPath()));
this.Type = finalType.Value;
}
else
{
if (this.IsOnline)
{
const string Format =
"No enumeration, enumMap, value or type field is available for the parameter with the path {0}.";
throw new ModelException(string.Format(CultureInfo.InvariantCulture, Format, this.GetPath()));
}
}

this.Type = finalType.Value;
}

private static List<KeyValuePair<string, int>> ReadEnumeration(EmberReader reader)
Expand Down

0 comments on commit a00c2af

Please sign in to comment.