55using System ;
66using System . Collections . Generic ;
77using System . Linq ;
8+ using System . Globalization ;
89
910namespace Moryx . ControlSystem . VisualInstructions
1011{
@@ -24,15 +25,28 @@ public static IReadOnlyList<string> PossibleResults(Type resultEnum, params stri
2425 /// <summary>
2526 /// Determine possible string buttons from enum result
2627 /// </summary>
28+ [ Obsolete ( "Use the 'InstructionResults' method instead!'" ) ]
2729 public static IReadOnlyList < InstructionResult > PossibleInstructionResults ( Type resultEnum , params string [ ] exceptions )
2830 {
2931 return ParseEnum ( resultEnum , exceptions ) . Select ( pair => new InstructionResult
3032 {
31- Key = pair . Value . ToString ( "D" ) ,
33+ Key = pair . Value . ToString ( "D" , CultureInfo . InvariantCulture ) ,
3234 DisplayValue = pair . Key
3335 } ) . ToList ( ) ;
3436 }
3537
38+ /// <summary>
39+ /// Determine possible string buttons from enum result
40+ /// </summary>
41+ public static InstructionResult [ ] InstructionResults ( Type resultEnum , params string [ ] exceptions )
42+ {
43+ return ParseEnum ( resultEnum , exceptions ) . Select ( pair => new InstructionResult
44+ {
45+ Key = pair . Value . ToString ( "D" , CultureInfo . InvariantCulture ) ,
46+ DisplayValue = pair . Key
47+ } ) . ToArray ( ) ;
48+ }
49+
3650 /// <summary>
3751 /// Parse the given result back to an enum value
3852 /// </summary>
@@ -46,7 +60,7 @@ public static int ResultToEnumValue(Type resultEnum, string result)
4660 /// </summary>
4761 public static int ResultToEnumValue ( Type resultEnum , InstructionResult result )
4862 {
49- return int . Parse ( result . Key ) ;
63+ return int . Parse ( result . Key , CultureInfo . InvariantCulture ) ;
5064 }
5165
5266 /// <summary>
@@ -79,7 +93,7 @@ public static TEnum ResultToGenericEnumValue<TEnum>(string result)
7993 public static TEnum ResultToGenericEnumValue < TEnum > ( InstructionResult result )
8094 where TEnum : Enum
8195 {
82- var numeric = int . Parse ( result . Key ) ;
96+ var numeric = int . Parse ( result . Key , CultureInfo . InvariantCulture ) ;
8397 return ( TEnum ) Enum . ToObject ( typeof ( TEnum ) , numeric ) ;
8498 }
8599
0 commit comments