Beispiel #1
0
        /// <summary>
        ///   Creates the header of the file
        /// </summary>
        /// <param name="storageEngine">Storage engine </param>
        /// <param name="creationDate"> The creation date </param>
        public void CreateEmptyDatabaseHeader(IStorageEngine storageEngine, long creationDate)
        {
            WriteVersion();
            WriteDatabaseId(storageEngine, creationDate);

            WriteNumberOfClasses(0, false);
            WriteFirstClassInfoOID(StorageEngineConstant.NullObjectId, false);
            WriteLastOdbCloseStatus(false, false);
            WriteDatabaseCharacterEncoding();

            // This is the position of the first block id. But it will always contain the position of the current id block
            FileSystemInterface.WriteLong(StorageEngineConstant.DatabaseHeaderFirstIdBlockPosition, false); // current id block position

            // Write an empty id block
            WriteIdBlock(-1, StorageEngineConstant.IdBlockSize, BlockStatus.BlockNotFull, 1, -1, false);
            Flush();

            var currentBlockInfo = new CurrentIdBlockInfo
            {
                CurrentIdBlockPosition = StorageEngineConstant.DatabaseHeaderFirstIdBlockPosition,
                CurrentIdBlockNumber   = 1,
                CurrentIdBlockMaxOid   = OIDFactory.BuildObjectOID(0)
            };

            storageEngine.SetCurrentIdBlockInfos(currentBlockInfo);
        }
        public void TestCompareCollection6()
        {
            const string dbName = "introspectortest6.odb";

            DeleteBase(dbName);
            var odb = OdbFactory.Open(dbName);

            var function = new VO.Login.Function("login");
            var profile  = new Profile("operator", function);
            var user     = new User("olivier smadja", "*****@*****.**", profile);
            IObjectInfoComparator comparator = new ObjectInfoComparator();
            var ci = ClassIntrospector.Introspect(user.GetType(), true).GetMainClassInfo();

            var storageEngine = ((global::NDatabase.Odb)odb).GetStorageEngine();

            var instanceInfo =
                (NonNativeObjectInfo)
                new ObjectIntrospector(storageEngine.GetClassInfoProvider()).GetMetaRepresentation(user, true, null,
                                                                                                   new InstrumentationCallbackForStore(null,
                                                                                                                                       false));
            // Sets attributes offsets - this is normally done by reading then from
            // disk, but in this junit,
            // we must set them manually
            var offsets = new[] { 1L, 2L, 3L };
            var ids     = new[] { 1, 2, 3 };

            instanceInfo.GetHeader().SetAttributesIdentification(offsets);
            instanceInfo.GetHeader().SetAttributesIds(ids);
            instanceInfo.GetHeader().SetOid(OIDFactory.BuildObjectOID(1));
            var nnoiProfile = (NonNativeObjectInfo)instanceInfo.GetAttributeValueFromId(3);

            nnoiProfile.SetOid(OIDFactory.BuildObjectOID(2));

            var nnoiFunctions = (NonNativeObjectInfo)nnoiProfile.GetAttributeValueFromId(1);

            nnoiFunctions.SetOid(OIDFactory.BuildObjectOID(3));

            var nnoi = (NonNativeObjectInfo)instanceInfo.GetAttributeValueFromId(ci.GetAttributeId("profile"));

            nnoi.GetHeader().SetAttributesIdentification(offsets);
            nnoi.GetHeader().SetAttributesIds(ids);
            profile.SetName("ope");
            var instanceInfo3 =
                (NonNativeObjectInfo)
                new ObjectIntrospector(storageEngine.GetClassInfoProvider()).GetMetaRepresentation(user, true, null,
                                                                                                   new InstrumentationCallbackForStore(null,
                                                                                                                                       false));

            instanceInfo3.GetHeader().SetOid(OIDFactory.BuildObjectOID(1));
            nnoiProfile = (NonNativeObjectInfo)instanceInfo3.GetAttributeValueFromId(3);
            nnoiProfile.SetOid(OIDFactory.BuildObjectOID(2));

            nnoiFunctions = (NonNativeObjectInfo)nnoiProfile.GetAttributeValueFromId(1);
            nnoiFunctions.SetOid(OIDFactory.BuildObjectOID(3));

            AssertTrue(comparator.HasChanged(instanceInfo, instanceInfo3));
            AssertEquals(1, comparator.GetNbChanges());

            odb.Close();
        }
Beispiel #3
0
        private static object CheckIfOid(AbstractObjectInfo objectInfo, int odbTypeId)
        {
            long l;

            if (odbTypeId == OdbType.ObjectOidId)
            {
                if (objectInfo.GetObject() is long)
                {
                    l = (long)objectInfo.GetObject();
                }
                else
                {
                    var oid = (OID)objectInfo.GetObject();
                    l = oid.ObjectId;
                }

                return(OIDFactory.BuildObjectOID(l));
            }

            if (odbTypeId == OdbType.ClassOidId)
            {
                if (objectInfo.GetObject() is long)
                {
                    l = (long)objectInfo.GetObject();
                }
                else
                {
                    l = Convert.ToInt64(objectInfo.GetObject().ToString());
                }
                return(OIDFactory.BuildClassOID(l));
            }

            return(ThrowIfNotFound(odbTypeId));
        }
Beispiel #4
0
        public virtual void TestEquals()
        {
            var oid1 = OIDFactory.BuildObjectOID(1);
            var oid2 = OIDFactory.BuildObjectOID(1);

            AssertEquals(oid1, oid2);
        }
Beispiel #5
0
        public virtual void TestPerformanceOid()
        {
            var size   = 300000;
            var oidMap = new OdbHashMap <OID, string>();

            // OID
            var timeOidMapCreation = new StopWatch();

            timeOidMapCreation.Start();
            // Creates a hashmap with 100000 Longs
            for (var i = 0; i < size; i++)
            {
                oidMap.Add(OIDFactory.BuildObjectOID(i), i.ToString());
            }
            timeOidMapCreation.End();
            var timeOidMapGet = new StopWatch();

            timeOidMapGet.Start();
            // get all map elements
            for (var i = 0; i < size; i++)
            {
                AssertNotNull(oidMap[OIDFactory.BuildObjectOID(i)]);
            }
            timeOidMapGet.End();
            Println(size + " objects : OID Map creation=" + timeOidMapCreation.GetDurationInMiliseconds() + " - get=" +
                    timeOidMapGet.GetDurationInMiliseconds());
        }
Beispiel #6
0
        static public void TestDictionnary()
        {
            int size = 100000;
            Dictionary <OID, Function> oids = new Dictionary <OID, Function>();
            long t0 = DateTime.Now.Ticks;
            long t  = DateTime.Now.Ticks;

            for (int i = 0; i < size; i++)
            {
                OID oid = OIDFactory.BuildObjectOID(i);
                oids[oid] = new Function("function i");
                //Console.WriteLine(oid.GetHashCode());
                if (i % 10000 == 0)
                {
                    Console.WriteLine(i + " - " + (DateTime.Now.Ticks - t) / 10000);
                    t = DateTime.Now.Ticks;
                }
            }
            for (int i = 0; i < size; i++)
            {
                Function f = null;
                oids.TryGetValue(OIDFactory.BuildObjectOID(i), out f);
                //Console.WriteLine(oid.GetHashCode());
                if (i % 10000 == 0)
                {
                    Console.WriteLine(i + " - " + (DateTime.Now.Ticks - t) / 10000);
                    t = DateTime.Now.Ticks;
                }
            }
            long t1 = DateTime.Now.Ticks;

            Console.WriteLine(" time is " + (t1 - t0) / 10000);
            Console.ReadLine();
        }
Beispiel #7
0
        public virtual void TestOIdInMap()
        {
            var oid1 = OIDFactory.BuildObjectOID(1);
            var oid2 = OIDFactory.BuildObjectOID(1);
            var map  = new OdbHashMap <OID, string>();

            map.Add(oid1, "oid1");
            AssertNotNull(map[oid2]);
        }
Beispiel #8
0
        public void It_should_properly_handle_update_after_trigger()
        {
            const string value = "insert_after";
            var          oid   = OIDFactory.BuildObjectOID(1L);

            SubjectUnderTest.ManageUpdateTriggerAfter(typeof(Warrior), null, value, oid);

            Assert.That(value, Is.EqualTo(_fakeUpdateTrigger.GetObject()));
            Assert.That(oid, Is.EqualTo(_fakeUpdateTrigger.GetOid()));
        }
Beispiel #9
0
        public void It_should_properly_handle_delete_before_trigger()
        {
            const string value = "delete_before";
            var          oid   = OIDFactory.BuildObjectOID(1L);

            SubjectUnderTest.ManageDeleteTriggerBefore(typeof(Warrior), value, oid);

            Assert.That(value, Is.EqualTo(_fakeDeleteTrigger.GetObject()));
            Assert.That(oid, Is.EqualTo(_fakeDeleteTrigger.GetOid()));
        }
Beispiel #10
0
        public void It_should_properly_handle_select_trigger()
        {
            const string value = "select";
            var          oid   = OIDFactory.BuildObjectOID(1L);

            SubjectUnderTest.ManageSelectTriggerAfter(typeof(Warrior), value, oid);

            Assert.That(value, Is.EqualTo(_fakeSelectTrigger.GetObject()));
            Assert.That(oid, Is.EqualTo(_fakeSelectTrigger.GetOid()));
        }
Beispiel #11
0
        public void TestIntrospectWithNull()
        {
            const string dbName = "TestIntrospectWithNull.odb";

            DeleteBase(dbName);
            var odb = OdbFactory.Open(dbName);

            var user = new User("olivier smadja", "*****@*****.**", null);
            IObjectInfoComparator comparator = new ObjectInfoComparator();

            var storageEngine = ((global::NDatabase.Odb)odb).GetStorageEngine();

            var instanceInfo =
                (NonNativeObjectInfo)
                new ObjectIntrospector(storageEngine.GetClassInfoProvider()).GetMetaRepresentation(user, true, null,
                                                                                                   new InstrumentationCallbackForStore(null,
                                                                                                                                       false));
            // Sets attributes offsets - this is normally done by reading then from
            // disk, but in this junit,
            // we must set them manually
            var offsets = new[] { 1L, 2L, 3L };
            var ids     = new[] { 1, 2, 3 };

            instanceInfo.GetHeader().SetAttributesIdentification(offsets);
            instanceInfo.GetHeader().SetAttributesIds(ids);
            instanceInfo.GetHeader().SetOid(OIDFactory.BuildObjectOID(1));
            object o           = instanceInfo.GetAttributeValueFromId(3);
            var    nnoiProfile = (NonNativeObjectInfo)o;

            nnoiProfile.SetOid(OIDFactory.BuildObjectOID(2));
            user.SetName("Olivier Smadja");
            user.SetEmail("*****@*****.**");
            user.SetProfile(new Profile("pname"));
            var instanceInfo3 =
                (NonNativeObjectInfo)
                new ObjectIntrospector(storageEngine.GetClassInfoProvider()).GetMetaRepresentation(user, true, null,
                                                                                                   new InstrumentationCallbackForStore(null,
                                                                                                                                       false));

            instanceInfo3.GetHeader().SetOid(OIDFactory.BuildObjectOID(1));
            nnoiProfile = (NonNativeObjectInfo)instanceInfo3.GetAttributeValueFromId(3);
            nnoiProfile.SetOid(OIDFactory.BuildObjectOID(2));
            AssertTrue(comparator.HasChanged(instanceInfo, instanceInfo3));
            AssertEquals(3, comparator.GetNbChanges());

            odb.Close();
        }
Beispiel #12
0
        public virtual void TestGetOIDThatDoesNotExist()
        {
            DeleteBase("getid.ndb");
            var function2 = new VO.Login.Function("f2");
            var odb       = Open("getid.ndb");
            var oid       = OIDFactory.BuildObjectOID(49);

            try
            {
                var o = odb.GetObjectFromId(oid);
            }
            catch (Exception e)
            {
                odb.Close();
                AssertFalse(e.Message.IndexOf(" does not exist in the database") == -1);
            }
        }
Beispiel #13
0
        public virtual void Test1()
        {
            var cwo = new ClassWithOid("test", OIDFactory.BuildObjectOID(47));

            DeleteBase("native-oid");
            var odb = Open("native-oid");

            odb.Store(cwo);
            odb.Close();
            odb = Open("native-oid");
            var query   = odb.Query <ClassWithOid>();
            var objects = query.Execute <ClassWithOid>();

            AssertEquals(1, objects.Count);
            var cwo2 = objects.GetFirst();

            AssertEquals(47, cwo2.GetOid().ObjectId);
        }
Beispiel #14
0
        public void ReadDatabaseHeader()
        {
            var version = ReadDatabaseVersion();

            StorageEngineConstant.CheckDbVersionCompatibility(version);

            var databaseIdsArray = new long[4];

            databaseIdsArray[0] = _fsi.ReadLong();
            databaseIdsArray[1] = _fsi.ReadLong();
            databaseIdsArray[2] = _fsi.ReadLong();
            databaseIdsArray[3] = _fsi.ReadLong();
            IDatabaseId databaseId = new DatabaseId(databaseIdsArray);

            var nbClasses          = ReadNumberOfClasses();
            var firstClassPosition = ReadFirstClassOid();

            if (nbClasses < 0)
            {
                throw new CorruptedDatabaseException(
                          NDatabaseError.NegativeClassNumberInHeader.AddParameter(nbClasses).AddParameter(firstClassPosition));
            }
            ReadLastOdbCloseStatus();
            ReadDatabaseCharacterEncoding();

            var currentBlockPosition = _fsi.ReadLong();

            // Gets the current id block number
            _fsi.SetReadPosition(currentBlockPosition + StorageEngineConstant.BlockIdOffsetForBlockNumber);
            var currentBlockIdNumber = _fsi.ReadInt();
            var blockMaxId           = OIDFactory.BuildObjectOID(_fsi.ReadLong());

            _storageEngine.SetDatabaseId(databaseId);

            var currentBlockInfo = new CurrentIdBlockInfo
            {
                CurrentIdBlockPosition = currentBlockPosition,
                CurrentIdBlockNumber   = currentBlockIdNumber,
                CurrentIdBlockMaxOid   = blockMaxId
            };

            _storageEngine.SetCurrentIdBlockInfos(currentBlockInfo);
        }
Beispiel #15
0
        public virtual void Test2()
        {
            var stopWatch = new StopWatch();

            stopWatch.Start();
            IDictionary objects = new Dictionary <object, object>();

            VO.Login.Function f = null;
            OID           oid   = null;
            ObjectWrapper ow    = null;
            var           i     = 0;

            for (i = 0; i < size; i++)
            {
                f   = new VO.Login.Function("function " + i);
                oid = OIDFactory.BuildObjectOID(i);
                objects.Add(oid, new ObjectWrapper(f, false));
                if (i < size / 2)
                {
                    ow = (ObjectWrapper)objects[oid];
                    ow.SetModified(true);
                }
            }
            i = 0;
            var nbModified = 0;
            // Now get all modified objects
            var iterator = objects.Keys.GetEnumerator();

            while (iterator.MoveNext())
            {
                oid = (OID)iterator.Current;
                ow  = (ObjectWrapper)objects[oid];
                if (ow.IsModified())
                {
                    nbModified++;
                }
                i++;
            }
            stopWatch.End();
            Println("time for 1 map =" + stopWatch.GetDurationInMiliseconds());
            AssertEquals(size / 2, nbModified);
        }
        protected void RemoveButton_Click(object sender, EventArgs e)
        {
            var dbPath = HttpContext.Current.Server.MapPath(DbPath);
            var id     = Convert.ToInt64(ID.Text);

            try
            {
                using (var odb = OdbFactory.Open(dbPath))
                {
                    odb.DeleteObjectWithId(OIDFactory.BuildObjectOID(id));
                }

                ID.Text           = "-1";
                ErrorMessage.Text = string.Empty;
            }
            catch (Exception exception)
            {
                ErrorMessage.Text = exception.Message;
            }
        }
Beispiel #17
0
        public virtual void Test2()
        {
            NeoDatis.Odb.Core.Transaction.ICache cache = NeoDatis.Odb.Impl.Core.Transaction.CacheFactory
                                                         .GetLocalCache(null, "temp");
            string s1 = "ola1";
            string s2 = "ola2";
            string s3 = "ola3";

            for (int i = 0; i < 1000 * 3; i += 3)
            {
                cache.StartInsertingObjectWithOid(s1, OIDFactory.BuildObjectOID(i + 1), null);
                cache.StartInsertingObjectWithOid(s2, OIDFactory.BuildObjectOID(i + 2), null);
                cache.StartInsertingObjectWithOid(s3, OIDFactory.BuildObjectOID(i + 3), null);
            }
            AssertEquals(1000, cache.InsertingLevelOf(s1));
            AssertEquals(1000, cache.InsertingLevelOf(s2));
            AssertEquals(1000, cache.InsertingLevelOf(s3));
            for (int i = 0; i < 1000; i++)
            {
                cache.EndInsertingObject(s1);
                cache.EndInsertingObject(s2);
                cache.EndInsertingObject(s3);
            }
            AssertEquals(0, cache.InsertingLevelOf(s1));
            AssertEquals(0, cache.InsertingLevelOf(s2));
            AssertEquals(0, cache.InsertingLevelOf(s3));
            cache.StartInsertingObjectWithOid(s1, OIDFactory.BuildObjectOID(1), null);
            cache.StartInsertingObjectWithOid(s1, OIDFactory.BuildObjectOID(1), null);
            cache.StartInsertingObjectWithOid(s1, OIDFactory.BuildObjectOID(1), null);
            cache.StartInsertingObjectWithOid(s2, OIDFactory.BuildObjectOID(2), null);
            cache.StartInsertingObjectWithOid(s3, OIDFactory.BuildObjectOID(3), null);
            AssertTrue(cache.IdOfInsertingObject(s1) != StorageEngineConstant.NullObjectId);
            AssertTrue(cache.IdOfInsertingObject(s2) != StorageEngineConstant.NullObjectId);
            AssertTrue(cache.IdOfInsertingObject(s3) != StorageEngineConstant.NullObjectId);
            cache.EndInsertingObject(s3);
            cache.EndInsertingObject(s2);
            cache.EndInsertingObject(s1);
            AssertTrue(cache.IdOfInsertingObject(s1) != StorageEngineConstant.NullObjectId);
            AssertTrue(cache.IdOfInsertingObject(s2) == StorageEngineConstant.NullObjectId);
            AssertTrue(cache.IdOfInsertingObject(s3) == StorageEngineConstant.NullObjectId);
        }
Beispiel #18
0
        public virtual void Test2()
        {
            var cache = (IOdbCache) new OdbCache();
            var s1    = "ola1";
            var s2    = "ola2";
            var s3    = "ola3";

            for (var i = 0; i < 1000 * 3; i += 3)
            {
                cache.StartInsertingObjectWithOid(s1, OIDFactory.BuildObjectOID(i + 1));
                cache.StartInsertingObjectWithOid(s2, OIDFactory.BuildObjectOID(i + 2));
                cache.StartInsertingObjectWithOid(s3, OIDFactory.BuildObjectOID(i + 3));
            }

            cache.StartInsertingObjectWithOid(s1, OIDFactory.BuildObjectOID(1));
            cache.StartInsertingObjectWithOid(s1, OIDFactory.BuildObjectOID(1));
            cache.StartInsertingObjectWithOid(s1, OIDFactory.BuildObjectOID(1));
            cache.StartInsertingObjectWithOid(s2, OIDFactory.BuildObjectOID(2));
            cache.StartInsertingObjectWithOid(s3, OIDFactory.BuildObjectOID(3));
            AssertTrue(cache.IdOfInsertingObject(s1) != StorageEngineConstant.NullObjectId);
            AssertTrue(cache.IdOfInsertingObject(s2) != StorageEngineConstant.NullObjectId);
            AssertTrue(cache.IdOfInsertingObject(s3) != StorageEngineConstant.NullObjectId);
        }
Beispiel #19
0
        public virtual void Test1()
        {
            var stopWatch = new StopWatch();

            stopWatch.Start();
            IDictionary loadedObjects   = new Dictionary <object, object>();
            IDictionary modifiedObjects = new Dictionary <object, object>();

            VO.Login.Function f = null;
            OID oid             = null;

            for (var i = 0; i < size; i++)
            {
                f   = new VO.Login.Function("function " + i);
                oid = OIDFactory.BuildObjectOID(i);
                loadedObjects.Add(oid, f);
                if (i < size / 2)
                {
                    modifiedObjects.Add(oid, f);
                }
            }
            var j          = 0;
            var nbModified = 0;
            // Now get all modified objects
            var iterator = modifiedObjects.Keys.GetEnumerator();

            while (iterator.MoveNext())
            {
                oid = (OID)iterator.Current;
                var o = modifiedObjects[oid];
                j++;
                nbModified++;
            }
            stopWatch.End();
            Println("time for 2 maps =" + stopWatch.GetDurationInMiliseconds());
            AssertEquals(size / 2, nbModified);
        }
Beispiel #20
0
        public object ReadAtomicNativeObjectInfoAsObject(int odbTypeId)
        {
            object o = null;

            switch (odbTypeId)
            {
            case OdbType.ByteId:
            {
                o = _fsi.ReadByte();
                break;
            }

            case OdbType.SByteId:
            {
                o = _fsi.ReadSByte();
                break;
            }

            case OdbType.BooleanId:
            {
                o = _fsi.ReadBoolean();
                break;
            }

            case OdbType.CharacterId:
            {
                o = _fsi.ReadChar();
                break;
            }

            case OdbType.FloatId:
            {
                o = _fsi.ReadFloat();
                break;
            }

            case OdbType.DoubleId:
            {
                o = _fsi.ReadDouble();
                break;
            }

            case OdbType.IntegerId:
            {
                o = _fsi.ReadInt();
                break;
            }

            case OdbType.UIntegerId:
            {
                o = _fsi.ReadUInt();
                break;
            }

            case OdbType.LongId:
            {
                o = _fsi.ReadLong();
                break;
            }

            case OdbType.ULongId:
            {
                o = _fsi.ReadULong();
                break;
            }

            case OdbType.ShortId:
            {
                o = _fsi.ReadShort();
                break;
            }

            case OdbType.UShortId:
            {
                o = _fsi.ReadUShort();
                break;
            }

            case OdbType.DecimalId:
            {
                o = _fsi.ReadBigDecimal();
                break;
            }

            case OdbType.DateId:
            {
                o = _fsi.ReadDate();
                break;
            }

            case OdbType.ObjectOidId:
            {
                var oid = _fsi.ReadLong();
                o = OIDFactory.BuildObjectOID(oid);
                break;
            }

            case OdbType.ClassOidId:
            {
                var cid = _fsi.ReadLong();
                o = OIDFactory.BuildClassOID(cid);
                break;
            }

            case OdbType.StringId:
            {
                o = _fsi.ReadString();
                break;
            }

            case OdbType.EnumId:
            {
                o = _fsi.ReadString();
                break;
            }
            }
            if (o == null)
            {
                throw new OdbRuntimeException(
                          NDatabaseError.NativeTypeNotSupported.AddParameter(odbTypeId).AddParameter(
                              OdbType.GetNameFromId(odbTypeId)));
            }
            return(o);
        }
Beispiel #21
0
        private OID ReadOid()
        {
            var oid = _fsi.ReadLong();

            return(oid == -1 ? null : OIDFactory.BuildObjectOID(oid));
        }
Beispiel #22
0
        internal static OID DecodeOid(byte[] bytes, int offset)
        {
            var oid = ByteArrayToLong(bytes, offset);

            return(oid == -1 ? null : OIDFactory.BuildObjectOID(oid));
        }
Beispiel #23
0
        public virtual object BuildOneInstance(AtomicNativeObjectInfo objectInfo)
        {
            int  odbTypeId = objectInfo.GetOdbTypeId();
            long l         = -1;

            switch (odbTypeId)
            {
            case ODBType.NullId:
            {
                return(null);
            }

            case ODBType.StringId:
            {
                return(objectInfo.GetObject());
            }

            case ODBType.DateId:
            {
                return(objectInfo.GetObject());
            }

            case ODBType.LongId:
            case ODBType.NativeLongId:
            {
                if (objectInfo.GetObject().GetType() == typeof(System.Int64))
                {
                    return(objectInfo.GetObject());
                }
                return(System.Convert.ToInt64(objectInfo.GetObject().ToString()));
            }

            case ODBType.IntegerId:
            case ODBType.NativeIntId:
            {
                if (objectInfo.GetObject().GetType() == typeof(int))
                {
                    return(objectInfo.GetObject());
                }
                return(System.Convert.ToInt32(objectInfo.GetObject().ToString()));
            }

            case ODBType.BooleanId:
            case ODBType.NativeBooleanId:
            {
                if (objectInfo.GetObject().GetType() == typeof(bool))
                {
                    return(objectInfo.GetObject());
                }
                return(System.Convert.ToBoolean(objectInfo.GetObject().ToString()));
            }

            case ODBType.ByteId:
            case ODBType.NativeByteId:
            {
                if (objectInfo.GetObject().GetType() == typeof(byte))
                {
                    return(objectInfo.GetObject());
                }
                return(System.Convert.ToByte(objectInfo.GetObject().ToString()));
            }

            case ODBType.ShortId:
            case ODBType.NativeShortId:
            {
                if (objectInfo.GetObject().GetType() == typeof(short))
                {
                    return(objectInfo.GetObject());
                }
                return(System.Convert.ToInt16(objectInfo.GetObject().ToString()));
            }

            case ODBType.FloatId:
            case ODBType.NativeFloatId:
            {
                if (objectInfo.GetObject().GetType() == typeof(float))
                {
                    return(objectInfo.GetObject());
                }
                return(System.Convert.ToSingle(objectInfo.GetObject().ToString()));
            }

            case ODBType.DoubleId:
            case ODBType.NativeDoubleId:
            {
                if (objectInfo.GetObject().GetType() == typeof(double))
                {
                    return(objectInfo.GetObject());
                }
                return(System.Convert.ToDouble(objectInfo.GetObject().ToString()));
            }

            case NeoDatis.Odb.Core.Layers.Layer2.Meta.ODBType.BigDecimalId:
            {
                return(System.Decimal.Parse(objectInfo.GetObject().ToString(), System.Globalization.NumberStyles.Any));
            }

            case NeoDatis.Odb.Core.Layers.Layer2.Meta.ODBType.BigIntegerId:
            {
                return(System.Decimal.Parse(objectInfo.GetObject().ToString(), System.Globalization.NumberStyles.Any));
            }

            case ODBType.CharacterId:
            case ODBType.NativeCharId:
            {
                if (objectInfo.GetObject().GetType() == typeof(char))
                {
                    return(objectInfo.GetObject());
                }
                return(objectInfo.GetObject().ToString()[0]);
            }

            case ODBType.ObjectOidId:
            {
                if (objectInfo.GetObject().GetType() == typeof(long))
                {
                    l = (long)objectInfo.GetObject();
                }
                else
                {
                    OID oid = (OID)objectInfo.GetObject();
                    l = oid.GetObjectId();
                }
                return(OIDFactory.BuildObjectOID(l));
            }

            case ODBType.ClassOidId:
            {
                if (objectInfo.GetObject().GetType() == typeof(long))
                {
                    l = (long)objectInfo.GetObject();
                }
                else
                {
                    l = System.Convert.ToInt64(objectInfo.GetObject().ToString());
                }
                return(OIDFactory.BuildClassOID(l));
            }

            default:
            {
                throw new ODBRuntimeException(NeoDatisError.InstanceBuilderNativeTypeInCollectionNotSupported
                                              .AddParameter(ODBType.GetNameFromId(odbTypeId)));
                break;
            }
            }
        }