Example #1
0
        public static bool IsNative(Type clazz)
        {
            OdbType odbType;
            var     success = TypesByName.TryGetValue(OdbClassNameResolver.GetFullName(clazz), out odbType);

            return(success || clazz.IsArray);
        }
Example #2
0
        public ClassInfo(Type underlyingType) : this()
        {
            _underlyingType = underlyingType;

            _fullClassName = OdbClassNameResolver.GetFullName(underlyingType);

            TypeCache.GetOrAdd(_fullClassName, UnderlyingType);
        }
Example #3
0
        public static OdbType GetFromClass(Type clazz)
        {
            if (clazz.IsEnum)
            {
                return(new OdbType(Enum._isPrimitive, EnumId, OdbClassNameResolver.GetFullName(clazz), 0));
            }

            var className = OdbClassNameResolver.GetFullName(clazz);

            // First check if it is a 'default type'
            OdbType odbType;
            var     success = TypesByName.TryGetValue(className, out odbType);

            if (success)
            {
                return(odbType);
            }

            // Then check if it is a 'non default type'
            success = CacheOfTypesByName.TryGetValue(className, out odbType);
            if (success)
            {
                return(odbType);
            }

            if (clazz.IsArray)
            {
                var type = new OdbType(Array._isPrimitive, ArrayId, Array.Name, 0)
                {
                    _subType = GetFromClass(clazz.GetElementType())
                };

                return(CacheOfTypesByName.GetOrAdd(className, type));
            }

            var nonNative = new OdbType(NonNative._isPrimitive, NonNativeId, className, 0);

            return(CacheOfTypesByName.GetOrAdd(className, nonNative));
        }