Exemplo n.º 1
0
            public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
            {
                var s = reader.ReadAsString();

                return(ShortCode.TryParse(s, out var c)
                    ? c
                    : null);
            }
Exemplo n.º 2
0
 public static bool TryParse(string s, out ShortCode c)
 {
     if (s != null && s.Length == 22)
     {
         var g = Decode(s);
         c = g.HasValue
             ? new ShortCode(g.Value)
             : null;
         return(g.HasValue);
         // c = new ShortCode(Decode(s).Value);
         // return true;
     }
     c = null;
     return(false);
 }