Ejemplo n.º 1
0
 static Optional <Color> TryParseColorHex111(string hex)
 {
     return
         (ScalarParser.ParseHex(hex.Substring(0, 1)).SelectMany(r =>
                                                                ScalarParser.ParseHex(hex.Substring(1, 1)).SelectMany(g =>
                                                                                                                      ScalarParser.ParseHex(hex.Substring(2, 1)).Select(b => new Color(r, g, b, 1)))));
 }
Ejemplo n.º 2
0
 static Optional <Color> TryParseColorHex2222(string hex)
 {
     return
         (ScalarParser.ParseHex(hex.Substring(0, 2)).SelectMany(r =>
                                                                ScalarParser.ParseHex(hex.Substring(2, 2)).SelectMany(g =>
                                                                                                                      ScalarParser.ParseHex(hex.Substring(4, 2)).SelectMany(b =>
                                                                                                                                                                            ScalarParser.ParseHex(hex.Substring(6, 2)).Select(a => new Color(r, g, b, a))))));
 }