Exemple #1
0
 public TypeSerializer GetSerializerByValueType(Type type)
 {
     if (type == null)
     {
         return(null);
     }
     if (_typesCache.TryGetValue(type, out var tSer))
     {
         return(tSer);
     }
     if (NumberSerializer.CanWrite(type))
     {
         tSer = NumberSerializer;
     }
     else if (StringSerializer.CanWrite(type))
     {
         tSer = StringSerializer;
     }
     else if (GuidSerializer.CanWrite(type))
     {
         tSer = GuidSerializer;
     }
     else if (BoolSerializer.CanWrite(type))
     {
         tSer = BoolSerializer;
     }
     else if (DateTimeSerializer.CanWrite(type))
     {
         tSer = DateTimeSerializer;
     }
     else if (TimeSpanSerializer.CanWrite(type))
     {
         tSer = TimeSpanSerializer;
     }
     else if (EnumSerializer.CanWrite(type))
     {
         tSer = EnumSerializer;
     }
     else if (SerializedObjectSerializer.CanWrite(type))
     {
         tSer = SerializedObjectSerializer;
     }
     else if (ByteArraySerializer.CanWrite(type))
     {
         tSer = ByteArraySerializer;
     }
     else if (CharSerializer.CanWrite(type))
     {
         tSer = CharSerializer;
     }
     else if (DateTimeOffsetSerializer.CanWrite(type))
     {
         tSer = DateTimeOffsetSerializer;
     }
     _typesCache[type] = tSer;
     return(tSer);
 }