public static bool TypesAreCompatible(ODBType type1, ODBType type2) { if (type1.IsArray() && type2.IsArray()) { return(TypesAreCompatible(type1.GetSubType(), type2.GetSubType())); } if (type1.GetName().Equals(type2.GetName())) { return(true); } if (type1.IsNative() && type2.IsNative()) { if (type1.IsEquivalent(type2)) { return(true); } return(false); } if (type1.IsNonNative() && type2.IsNonNative()) { return((type1.GetNativeClass() == type2.GetNativeClass()) || (type1.GetNativeClass ().IsAssignableFrom(type2.GetNativeClass()))); } return(false); }
public static bool TypesAreCompatible(ODBType type1, ODBType type2) { if (type1.IsArray() && type2.IsArray()) { return TypesAreCompatible(type1.GetSubType(), type2.GetSubType()); } if (type1.GetName().Equals(type2.GetName())) { return true; } if (type1.IsNative() && type2.IsNative()) { if (type1.IsEquivalent(type2)) { return true; } return false; } if (type1.IsNonNative() && type2.IsNonNative()) { return (type1.GetNativeClass() == type2.GetNativeClass()) || (type1.GetNativeClass ().IsAssignableFrom(type2.GetNativeClass())); } return false; }
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); }