Exemplo n.º 1
0
        public IFieldHandler SpecializeLoadForType(Type type, IFieldHandler?typeHandler, IFieldHandlerLogger?logger)
        {
            if (_type != type)
            {
                GenerateType(type);
            }
            if (_type == type)
            {
                return(this);
            }
            if (!IsCompatibleWithCore(type))
            {
                return(this);
            }
            var arguments        = type.GetGenericArguments();
            var wantedKeyHandler = default(IFieldHandler);

            if (typeHandler is ODBSetFieldHandler dictTypeHandler)
            {
                wantedKeyHandler = dictTypeHandler._keysHandler;
            }

            var specializedKeyHandler = _keysHandler.SpecializeLoadForType(arguments[0], wantedKeyHandler, logger);

            if (wantedKeyHandler == specializedKeyHandler)
            {
                return(typeHandler);
            }

            var res = new ODBSetFieldHandler(_odb, _configuration, specializedKeyHandler);

            res.GenerateType(type);
            return(res);
        }
Exemplo n.º 2
0
 public override bool TypeSupported(Type type)
 {
     if (ODBDictionaryFieldHandler.IsCompatibleWithStatic(type, FieldHandlerOptions.None))
     {
         return(true);
     }
     if (ODBSetFieldHandler.IsCompatibleWithStatic(type, FieldHandlerOptions.None))
     {
         return(true);
     }
     if (base.TypeSupported(type))
     {
         return(true);
     }
     if (DBObjectFieldHandler.IsCompatibleWith(type))
     {
         return(true);
     }
     return(false);
 }
Exemplo n.º 3
0
        public override IFieldHandler?CreateFromType(Type type, FieldHandlerOptions options)
        {
            if (ODBDictionaryFieldHandler.IsCompatibleWithStatic(type, options))
            {
                return(new ODBDictionaryFieldHandler(_odb, type, this));
            }
            if (ODBSetFieldHandler.IsCompatibleWithStatic(type, options))
            {
                return(new ODBSetFieldHandler(_odb, type, this));
            }
            var result = base.CreateFromType(type, options);

            if (result != null)
            {
                return(result);
            }
            if (DBObjectFieldHandler.IsCompatibleWith(type))
            {
                return(new DBObjectFieldHandler(_odb, type));
            }
            return(null);
        }