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

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

            _fullClassName = OdbClassNameResolver.GetFullName(underlyingType);

            TypeCache.GetOrAdd(_fullClassName, UnderlyingType);
        }
Beispiel #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));
        }
Beispiel #4
0
 internal void SetFullClassName(string fullClassName)
 {
     _fullClassName = fullClassName;
     _className     = OdbClassNameResolver.GetClassName(fullClassName);
     _namespace     = OdbClassNameResolver.GetNamespace(fullClassName);
 }
Beispiel #5
0
        public override string ToString()
        {
            var buffer = new StringBuilder(_classInfo.FullClassName).Append("(").Append(GetOid()).Append(")=");

            if (_attributeValues == null)
            {
                buffer.Append("null attribute values");
                return(buffer.ToString());
            }

            for (var i = 0; i < _attributeValues.Length; i++)
            {
                if (i != 0)
                {
                    buffer.Append(",");
                }

                var attributeName = (_classInfo != null
                                         ? (_classInfo.GetAttributeInfo(i)).GetName()
                                         : "?");

                buffer.Append(attributeName).Append("=");
                object @object = _attributeValues[i];

                if (@object == null)
                {
                    buffer.Append(" null object - should not happen , ");
                }
                else
                {
                    var type = OdbType.GetFromClass(_attributeValues[i].GetType());
                    if (@object is NonNativeNullObjectInfo)
                    {
                        buffer.Append("null");
                        continue;
                    }
                    if (@object is NonNativeDeletedObjectInfo)
                    {
                        buffer.Append("deleted object");
                        continue;
                    }
                    var noi = @object as NativeObjectInfo;
                    if (noi != null)
                    {
                        buffer.Append(noi);
                        continue;
                    }
                    var nnoi = @object as NonNativeObjectInfo;
                    if (nnoi != null)
                    {
                        buffer.Append("@").Append(nnoi.GetClassInfo().FullClassName).Append("(id=").Append(
                            nnoi.GetOid()).Append(")");
                        continue;
                    }
                    if (@object is ObjectReference)
                    {
                        buffer.Append(@object);
                        continue;
                    }
                    buffer.Append("@").Append(OdbClassNameResolver.GetClassName(type.Name));
                }
            }

            return(buffer.ToString());
        }