public static bool TryGetKnownColor(string color, out int rgb) { if (color == null) { throw new ArgumentNullException(nameof(color)); } return(KnownColors.TryGetValue(color, out rgb)); }
public static Color?AsColor(this string?attr) { if (string.IsNullOrEmpty(attr)) { return(null); } var name = attr; if (KnownColors.TryGetValue(name, out var c)) { return(c); } try { return(ParseFromString(name)); } catch (Exception) { return(null); } }