Пример #1
0
 public virtual IFieldHandler CreateFromType(Type type, FieldHandlerOptions options)
 {
     if (EnumFieldHandler.IsCompatibleWith(type))
     {
         return(new EnumFieldHandler(type));
     }
     foreach (var fieldHandler in BasicSerializersFactory.FieldHandlers)
     {
         if (fieldHandler.IsCompatibleWith(type, options))
         {
             return(fieldHandler);
         }
     }
     if (ListFieldHandler.IsCompatibleWith(type))
     {
         return(new ListFieldHandler(_provider.FieldHandlerFactory, _provider.TypeConvertorGenerator, type));
     }
     if (DictionaryFieldHandler.IsCompatibleWith(type))
     {
         return(new DictionaryFieldHandler(_provider.FieldHandlerFactory, _provider.TypeConvertorGenerator, type));
     }
     if (NullableFieldHandler.IsCompatibleWith(type))
     {
         return(new NullableFieldHandler(_provider.FieldHandlerFactory, _provider.TypeConvertorGenerator, type));
     }
     return(null);
 }
Пример #2
0
 public virtual bool TypeSupported(Type type)
 {
     if (EnumFieldHandler.IsCompatibleWith(type))
     {
         return(true);
     }
     foreach (var fieldHandler in BasicSerializersFactory.FieldHandlers)
     {
         if (fieldHandler.IsCompatibleWith(type, FieldHandlerOptions.None))
         {
             return(true);
         }
     }
     if (ListFieldHandler.IsCompatibleWith(type))
     {
         return(true);
     }
     if (DictionaryFieldHandler.IsCompatibleWith(type))
     {
         return(true);
     }
     if (NullableFieldHandler.IsCompatibleWith(type))
     {
         return(true);
     }
     return(false);
 }