Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Globalization;

namespace Moryx.ControlSystem.VisualInstructions
{
Expand All @@ -24,15 +25,28 @@
/// <summary>
/// Determine possible string buttons from enum result
/// </summary>
[Obsolete("Use the 'InstructionResults' method instead!'")]
public static IReadOnlyList<InstructionResult> PossibleInstructionResults(Type resultEnum, params string[] exceptions)
{
return ParseEnum(resultEnum, exceptions).Select(pair => new InstructionResult
{
Key = pair.Value.ToString("D"),
Key = pair.Value.ToString("D", CultureInfo.InvariantCulture),
DisplayValue = pair.Key
}).ToList();
}

/// <summary>
/// Determine possible string buttons from enum result
/// </summary>
public static InstructionResult[] InstructionResults(Type resultEnum, params string[] exceptions)
{
return ParseEnum(resultEnum, exceptions).Select(pair => new InstructionResult
{
Key = pair.Value.ToString("D", CultureInfo.InvariantCulture),
DisplayValue = pair.Key
}).ToArray();
}

/// <summary>
/// Parse the given result back to an enum value
/// </summary>
Expand All @@ -46,7 +60,7 @@
/// </summary>
public static int ResultToEnumValue(Type resultEnum, InstructionResult result)
{
return int.Parse(result.Key);
return int.Parse(result.Key, CultureInfo.InvariantCulture);
}

/// <summary>
Expand All @@ -57,8 +71,8 @@
if(response.SelectedResult != null)
return ResultToEnumValue(resultEnum, response.SelectedResult);

if (response.Result != null)

Check warning on line 74 in src/Moryx.ControlSystem/VisualInstructions/EnumInstructionResult.cs

View workflow job for this annotation

GitHub Actions / Build / Build

'ActiveInstructionResponse.Result' is obsolete: 'Use result object from 'SelectedResult' instead'

Check warning on line 74 in src/Moryx.ControlSystem/VisualInstructions/EnumInstructionResult.cs

View workflow job for this annotation

GitHub Actions / UnitTests / UnitTests

'ActiveInstructionResponse.Result' is obsolete: 'Use result object from 'SelectedResult' instead'

Check warning on line 74 in src/Moryx.ControlSystem/VisualInstructions/EnumInstructionResult.cs

View workflow job for this annotation

GitHub Actions / IntegrationTests / IntegrationTests

'ActiveInstructionResponse.Result' is obsolete: 'Use result object from 'SelectedResult' instead'
return ResultToEnumValue(resultEnum, response.Result);

Check warning on line 75 in src/Moryx.ControlSystem/VisualInstructions/EnumInstructionResult.cs

View workflow job for this annotation

GitHub Actions / Build / Build

'ActiveInstructionResponse.Result' is obsolete: 'Use result object from 'SelectedResult' instead'

Check warning on line 75 in src/Moryx.ControlSystem/VisualInstructions/EnumInstructionResult.cs

View workflow job for this annotation

GitHub Actions / UnitTests / UnitTests

'ActiveInstructionResponse.Result' is obsolete: 'Use result object from 'SelectedResult' instead'

Check warning on line 75 in src/Moryx.ControlSystem/VisualInstructions/EnumInstructionResult.cs

View workflow job for this annotation

GitHub Actions / IntegrationTests / IntegrationTests

'ActiveInstructionResponse.Result' is obsolete: 'Use result object from 'SelectedResult' instead'

throw new ArgumentException("No result found on response", nameof(response));
}
Expand All @@ -79,7 +93,7 @@
public static TEnum ResultToGenericEnumValue<TEnum>(InstructionResult result)
where TEnum : Enum
{
var numeric = int.Parse(result.Key);
var numeric = int.Parse(result.Key, CultureInfo.InvariantCulture);
return (TEnum)Enum.ToObject(typeof(TEnum), numeric);
}

Expand Down
Loading