@@ -41,9 +41,21 @@ public Color ConvertFrom(CommandParser parser, CultureInfo culture, string? valu
4141 return default ;
4242 }
4343
44+ // Hex colors rgb, rrggbb, rrggbbaa
45+ if ( HexColorRegex . IsMatch ( value ) )
46+ {
47+ return Color . ParseHex ( value ) ;
48+ }
49+
50+ // Named colors
51+ IDictionary < string , Color > table = ColorConstantsTable . Value ;
52+ if ( table . TryGetValue ( value , out Color color ) )
53+ {
54+ return color ;
55+ }
56+
4457 // Numeric r,g,b - r,g,b,a
4558 char separator = culture . TextInfo . ListSeparator [ 0 ] ;
46-
4759 if ( value . IndexOf ( separator ) != - 1 )
4860 {
4961 string [ ] components = value . Split ( separator ) ;
@@ -70,15 +82,7 @@ public Color ConvertFrom(CommandParser parser, CultureInfo culture, string? valu
7082 }
7183 }
7284
73- // Hex colors rgb, rrggbb, rrggbbaa
74- if ( HexColorRegex . IsMatch ( value ) )
75- {
76- return Color . ParseHex ( value ) ;
77- }
78-
79- // Named colors
80- IDictionary < string , Color > table = ColorConstantsTable . Value ;
81- return table . TryGetValue ( value , out Color color ) ? color : default ;
85+ return default ;
8286 }
8387
8488 private static IDictionary < string , Color > InitializeColorConstantsTable ( )
0 commit comments