Пример #1
0
        public IFieldHandler SpecializeLoadForType(Type type, IFieldHandler?typeHandler)
        {
            if (_type != type)
            {
                GenerateType(type);
            }
            if (_type == type)
            {
                return(this);
            }
            if (!IsCompatibleWithCore(type))
            {
                return(this);
            }
            var arguments          = type.GetGenericArguments();
            var wantedKeyHandler   = default(IFieldHandler);
            var wantedValueHandler = default(IFieldHandler);

            if (typeHandler is ODBDictionaryFieldHandler dictTypeHandler)
            {
                wantedKeyHandler   = dictTypeHandler._keysHandler;
                wantedValueHandler = dictTypeHandler._valuesHandler;
            }
            var specializedKeyHandler   = _keysHandler.SpecializeLoadForType(arguments[0], wantedKeyHandler);
            var specializedValueHandler = _valuesHandler.SpecializeLoadForType(arguments[1], wantedValueHandler);

            if (wantedKeyHandler == specializedKeyHandler && (wantedValueHandler == specializedValueHandler || wantedValueHandler.HandledType() == specializedValueHandler.HandledType()))
            {
                return(typeHandler);
            }
            var res = new ODBDictionaryFieldHandler(_odb, _configuration, specializedKeyHandler, specializedValueHandler);

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

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