public override bool Equals(object obj) { if (obj == null || obj.GetType() != typeof(ODBType )) { return(false); } ODBType type = (ODBType )obj; return(GetId() == type.GetId()); }
static ODBType() { // Not used in Java, for .Net compatibility // Not used in Java, for .Net compatibility //public final static ODBType MAP = new ODBType(false,MAP_ID, "java.util.AbstractMap", 0, AbstractMap.class); NeoDatis.Tool.Wrappers.List.IOdbList <ODBType > allTypes = new NeoDatis.Tool.Wrappers.List.OdbArrayList <ODBType >(100); //// DO NOT FORGET DO ADD THE TYPE IN THIS LIST WHEN CREATING A NEW ONE!!! allTypes.Add(Null); allTypes.Add(NativeBoolean); allTypes.Add(NativeByte); allTypes.Add(NativeChar); allTypes.Add(NativeShort); allTypes.Add(NativeInt); allTypes.Add(NativeLong); allTypes.Add(NativeFloat); allTypes.Add(NativeDouble); allTypes.Add(Byte); allTypes.Add(Short); allTypes.Add(Integer); allTypes.Add(Long); allTypes.Add(Float); allTypes.Add(Double); allTypes.Add(BigDecimal); allTypes.Add(BigInteger); allTypes.Add(Character); allTypes.Add(Boolean); allTypes.Add(Date); allTypes.Add(DateSql); allTypes.Add(DateTimestamp); allTypes.Add(String); allTypes.Add(Enum); allTypes.Add(Collection); allTypes.Add(CollectionGeneric); allTypes.Add(Array); allTypes.Add(Map); allTypes.Add(Oid); allTypes.Add(ObjectOid); allTypes.Add(ClassOid); allTypes.Add(NonNative); ODBType type = null; for (int i = 0; i < allTypes.Count; i++) { type = allTypes[i]; typesByName[type.GetName()] = type; typesById[type.GetId()] = type; } }
protected virtual NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo GetNativeObjectInfoInternal (NeoDatis.Odb.Core.Layers.Layer2.Meta.ODBType type, object o, bool recursive , System.Collections.Generic.IDictionary <object, NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo > alreadyReadObjects, NeoDatis.Odb.Core.Layers.Layer1.Introspector.IIntrospectionCallback callback) { NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo aoi = null; if (type.IsAtomicNative()) { if (o == null) { aoi = new NeoDatis.Odb.Core.Layers.Layer2.Meta.NullNativeObjectInfo(type.GetId()); } else { aoi = new NeoDatis.Odb.Core.Layers.Layer2.Meta.AtomicNativeObjectInfo(o, type .GetId()); } } else { if (type.IsCollection()) { aoi = IntrospectCollection((System.Collections.ICollection)o, recursive, alreadyReadObjects , type, callback); } else { if (type.IsArray()) { if (o == null) { aoi = new NeoDatis.Odb.Core.Layers.Layer2.Meta.ArrayObjectInfo(null); } else { // Gets the type of the elements of the array string realArrayClassName = OdbClassUtil.GetFullName(o.GetType().GetElementType()); NeoDatis.Odb.Core.Layers.Layer2.Meta.ArrayObjectInfo aroi = null; if (recursive) { aroi = IntrospectArray(o, recursive, alreadyReadObjects, type, callback); } else { aroi = new NeoDatis.Odb.Core.Layers.Layer2.Meta.ArrayObjectInfo((object[])o ); } aroi.SetRealArrayComponentClassName(realArrayClassName); aoi = aroi; } } else { if (type.IsMap()) { if (o == null) { aoi = new NeoDatis.Odb.Core.Layers.Layer2.Meta.MapObjectInfo(null, type, type.GetDefaultInstanciationClass ().FullName); } else { MapObjectInfo moi = null; string realMapClassName = OdbClassUtil.GetFullName(o.GetType()); bool isGeneric = o.GetType().IsGenericType; if (isGeneric) { moi = new MapObjectInfo(IntrospectGenericMap((System.Collections.Generic.IDictionary <object, object>)o, recursive, alreadyReadObjects, callback), type, realMapClassName); } else { moi = new MapObjectInfo(IntrospectNonGenericMap((System.Collections.IDictionary)o, recursive, alreadyReadObjects, callback), type, realMapClassName); } if (realMapClassName.IndexOf("$") != -1) { moi.SetRealMapClassName(OdbClassUtil.GetFullName(type.GetDefaultInstanciationClass())); } aoi = moi; } } else { if (type.IsEnum()) { System.Enum enumObject = (System.Enum)o; if (enumObject == null) { aoi = new NeoDatis.Odb.Core.Layers.Layer2.Meta.NullNativeObjectInfo(type.GetSize( )); } else { Type t = enumObject.GetType(); string enumClassName = enumObject == null ? null : OdbClassUtil.GetFullName(enumObject.GetType()); // Here we must check if the enum is already in the meta model. Enum must be stored in the meta // model to optimize its storing as we need to keep track of the enum class // for each enum stored. So instead of storing the enum class name, we can store enum class id, a long // instead of the full enum class name string NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo ci = GetClassInfo(enumClassName); string enumValue = enumObject == null ? null : enumObject.ToString(); aoi = new NeoDatis.Odb.Core.Layers.Layer2.Meta.EnumNativeObjectInfo(ci, enumValue ); } } } } } } return(aoi); }
private NeoDatis.Odb.Core.Layers.Layer2.Meta.ArrayObjectInfo IntropectAtomicNativeArray (object array, NeoDatis.Odb.Core.Layers.Layer2.Meta.ODBType type) { int length = NeoDatis.Tool.Wrappers.OdbReflection.GetArrayLength(array); NeoDatis.Odb.Core.Layers.Layer2.Meta.AtomicNativeObjectInfo anoi = null; object[] arrayCopy = new object[length]; int typeId = 0; for (int i = 0; i < length; i++) { object o = NeoDatis.Tool.Wrappers.OdbReflection.GetArrayElement(array, i); if (o != null) { // If object is not null, try to get the exact type typeId = NeoDatis.Odb.Core.Layers.Layer2.Meta.ODBType.GetFromClass(o.GetType()).GetId (); anoi = new NeoDatis.Odb.Core.Layers.Layer2.Meta.AtomicNativeObjectInfo(o, typeId); arrayCopy[i] = anoi; } else { // Else take the declared type arrayCopy[i] = new NeoDatis.Odb.Core.Layers.Layer2.Meta.NullNativeObjectInfo(type .GetId()); } } NeoDatis.Odb.Core.Layers.Layer2.Meta.ArrayObjectInfo aoi = new NeoDatis.Odb.Core.Layers.Layer2.Meta.ArrayObjectInfo (arrayCopy, NeoDatis.Odb.Core.Layers.Layer2.Meta.ODBType.Array, type.GetId()); return(aoi); }
private NeoDatis.Odb.Core.Layers.Layer2.Meta.ArrayObjectInfo IntrospectArray(object array, bool introspect, System.Collections.Generic.IDictionary <object, NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo > alreadyReadObjects, NeoDatis.Odb.Core.Layers.Layer2.Meta.ODBType valueType, NeoDatis.Odb.Core.Layers.Layer1.Introspector.IIntrospectionCallback callback) { int length = NeoDatis.Tool.Wrappers.OdbReflection.GetArrayLength(array); System.Type elementType = array.GetType().GetElementType(); NeoDatis.Odb.Core.Layers.Layer2.Meta.ODBType type = NeoDatis.Odb.Core.Layers.Layer2.Meta.ODBType .GetFromClass(elementType); if (type.IsAtomicNative()) { return(IntropectAtomicNativeArray(array, type)); } if (!introspect) { return(new NeoDatis.Odb.Core.Layers.Layer2.Meta.ArrayObjectInfo((object[])array)); } object[] arrayCopy = new object[length]; for (int i = 0; i < length; i++) { object o = NeoDatis.Tool.Wrappers.OdbReflection.GetArrayElement(array, i); NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo ci = null; if (o != null) { ci = GetClassInfo(OdbClassUtil.GetFullName(o.GetType())); NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo aoi = GetObjectInfo(o, ci , introspect, alreadyReadObjects, callback); arrayCopy[i] = aoi; } else { arrayCopy[i] = new NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeNullObjectInfo(); } } NeoDatis.Odb.Core.Layers.Layer2.Meta.ArrayObjectInfo arrayOfAoi = new NeoDatis.Odb.Core.Layers.Layer2.Meta.ArrayObjectInfo (arrayCopy, valueType, type.GetId()); return(arrayOfAoi); }