Skip to content

Commit

Permalink
Converted GetValues()-method to property.
Browse files Browse the repository at this point in the history
  • Loading branch information
Spontifixus committed Mar 23, 2021
1 parent 413dde3 commit e970bc7
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 13 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ var result = responseFrame.GetValue<RscpInt32>(RscpTag.TAG_BAT_CHARGE_CYCLES);
In other cases, for example if you want to retrieve a list of error messages, you'd rather fetch all values:

```csharp
var responseValues = responseFrame.GetValues();
var responseValues = responseFrame.Values;
```

You can access the value's value by means of the `Value` property. If the value is an `RscpContainer` that contains other values you need to use its `Children` property.
Expand Down
2 changes: 1 addition & 1 deletion Source/AM.E3dc.Rscp.Data/AM.E3dc.Rscp.Data.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<Version>1.0.0</Version>
<Version>1.0.1</Version>
<Company></Company>
<Product>am-e3dc</Product>
<PackageId>AM.E3dc.Rscp.Data</PackageId>
Expand Down
15 changes: 6 additions & 9 deletions Source/AM.E3dc.Rscp.Data/RscpFrame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,12 @@ internal set
/// <value><c>true</c> if an error was returned; <c>false</c> otherwise.</value>
public bool HasError => this.values.Values.Any(rscpValue => rscpValue.DataType == RscpDataType.Error);

/// <summary>
/// Gets the values that are contained in this frame.
/// </summary>
/// <value>A readonly collection of <see cref="RscpValue"/>.</value>
public IReadOnlyList<RscpValue> Values => new ReadOnlyCollection<RscpValue>(this.values.Values.ToArray());

/// <summary>
/// Tries to receive the value with the specified tag and the specified value type from the frame.
/// </summary>
Expand All @@ -154,15 +160,6 @@ public bool TryGetValue<TValue>(RscpTag tag, out TValue value)
return false;
}

/// <summary>
/// Gets the values that are contained in this frame.
/// </summary>
/// <returns>A readonly collection of <see cref="RscpValue"/>.</returns>
public IReadOnlyList<RscpValue> GetValues()
{
return new ReadOnlyCollection<RscpValue>(this.values.Values.ToArray());
}

/// <summary>
/// Gets the errors that are contained in this instance's values.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion Source/AM.E3dc.Rscp/AM.E3dc.Rscp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<Version>1.0.0</Version>
<Version>1.0.1</Version>
<Company></Company>
<Product>am-e3dc</Product>
<PackageId>AM.E3dc.Rscp</PackageId>
Expand Down
2 changes: 1 addition & 1 deletion Tests/AM.E3dc.Rscp.Data.Tests/RscpFrameFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public void CanAddAndRetrieveMultipleValues()
this.subject.TryGetValue<RscpInt8>(RscpTag.TAG_RSCP_AUTHENTICATION, out var retrievedValue2).Should().BeTrue();
retrievedValue2.Should().BeEquivalentTo(value2);

this.subject.GetValues().Should().BeEquivalentTo(value1, value2);
this.subject.Values.Should().BeEquivalentTo(value1, value2);

this.subject.HasError.Should().BeFalse();
this.subject.GetErrors().Should().BeEmpty();
Expand Down

0 comments on commit e970bc7

Please sign in to comment.