Exemplo n.º 1
0
 public static bool TryGetKnownColor(string color, out int rgb)
 {
     if (color == null)
     {
         throw new ArgumentNullException(nameof(color));
     }
     return(KnownColors.TryGetValue(color, out rgb));
 }
Exemplo n.º 2
0
        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);
            }
        }