예제 #1
0
 internal TableInfo(uint id, string name, ITableInfoResolver tableInfoResolver)
 {
     Id   = id;
     Name = name;
     _tableInfoResolver    = tableInfoResolver;
     NeedStoreSingletonOid = false;
 }
예제 #2
0
파일: ObjectDB.cs 프로젝트: Waizik/BTDB
        public void Open(IKeyValueDB keyValueDB, bool dispose, DBOptions options)
        {
            _keyValueDB = keyValueDB ?? throw new ArgumentNullException(nameof(keyValueDB));
            _dispose    = dispose;
            _type2Name  = options.CustomType2NameRegistry ?? new Type2NameRegistry();
            _polymorphicTypesRegistry = new PolymorphicTypesRegistry();
            AutoRegisterTypes         = options.AutoRegisterType;
            ActualOptions             = options;
            SymmetricCipher           = options.SymmetricCipher ?? new InvalidSymmetricCipher();

            _tableInfoResolver     = new TableInfoResolver(keyValueDB, this);
            _tablesInfo            = new TablesInfo(_tableInfoResolver);
            _relationsInfoResolver = new RelationInfoResolver(this);
            _relationsInfo         = new RelationsInfo(_relationsInfoResolver);

            using var tr = _keyValueDB.StartTransaction();
            _lastObjId   = (long)tr.GetUlong(0);
            _lastDictId  = tr.GetUlong(1);
            if (_lastObjId == 0)
            {
                if (tr.FindLastKey(AllObjectsPrefix))
                {
                    _lastObjId = (long)PackUnpack.UnpackVUInt(tr.GetKey().Slice(AllObjectsPrefixLen));
                }
            }
            _tablesInfo.LoadTables(LoadTablesEnum(tr));
            _relationsInfo.LoadRelations(LoadRelationNamesEnum(tr));
            if (_lastDictId == 0)
            {
                if (tr.FindExactKey(LastDictIdKey))
                {
                    _lastDictId = PackUnpack.UnpackVUInt(tr.GetValue());
                }
            }
        }
예제 #3
0
파일: TableInfo.cs 프로젝트: Bobris/BTDB
 internal TableInfo(uint id, string name, ITableInfoResolver tableInfoResolver)
 {
     _id = id;
     _name = name;
     _tableInfoResolver = tableInfoResolver;
     NeedStoreSingletonOid = false;
 }
예제 #4
0
파일: ObjectDB.cs 프로젝트: saryn/BTDB
 public void Open(IKeyValueDB keyValueDB, bool dispose)
 {
     if (keyValueDB == null)
     {
         throw new ArgumentNullException(nameof(keyValueDB));
     }
     _keyValueDB            = keyValueDB;
     _dispose               = dispose;
     _tableInfoResolver     = new TableInfoResolver(keyValueDB, this);
     _tablesInfo            = new TablesInfo(_tableInfoResolver);
     _relationsInfoResolver = new RelationInfoResolver(this);
     _relationsInfo         = new RelationsInfo(_relationsInfoResolver);
     _lastObjId             = 0;
     using (var tr = _keyValueDB.StartTransaction())
     {
         tr.SetKeyPrefix(AllObjectsPrefix);
         if (tr.FindLastKey())
         {
             _lastObjId = (long)new KeyValueDBKeyReader(tr).ReadVUInt64();
         }
         _tablesInfo.LoadTables(LoadTablesEnum(tr));
         _relationsInfo.LoadRelations(LoadRelationNamesEnum(tr));
         tr.SetKeyPrefix(null);
         if (tr.FindExactKey(LastDictIdKey))
         {
             _lastDictId = new ByteArrayReader(tr.GetValueAsByteArray()).ReadVUInt64();
         }
     }
 }
예제 #5
0
        public void Open(IKeyValueDB keyValueDB, bool dispose, DBOptions options)
        {
            if (keyValueDB == null)
            {
                throw new ArgumentNullException(nameof(keyValueDB));
            }
            _keyValueDB = keyValueDB;
            _dispose    = dispose;
            _type2Name  = options.CustomType2NameRegistry ?? new Type2NameRegistry();
            _polymorphicTypesRegistry = new PolymorphicTypesRegistry();
            AutoRegisterTypes         = options.AutoRegisterType;
            ActualOptions             = options;
            _symmetricCipher          = options.SymmetricCipher ?? new InvalidSymmetricCipher();

            _tableInfoResolver     = new TableInfoResolver(keyValueDB, this);
            _tablesInfo            = new TablesInfo(_tableInfoResolver);
            _relationsInfoResolver = new RelationInfoResolver(this);
            _relationsInfo         = new RelationsInfo(_relationsInfoResolver);

            using (var tr = _keyValueDB.StartTransaction())
            {
                _lastObjId  = (long)tr.GetUlong(0);
                _lastDictId = tr.GetUlong(1);
                if (_lastObjId == 0)
                {
                    tr.SetKeyPrefix(AllObjectsPrefix);
                    if (tr.FindLastKey())
                    {
                        _lastObjId = (long)new KeyValueDBKeyReader(tr).ReadVUInt64();
                    }
                }
                _tablesInfo.LoadTables(LoadTablesEnum(tr));
                _relationsInfo.LoadRelations(LoadRelationNamesEnum(tr));
                if (_lastDictId == 0)
                {
                    tr.SetKeyPrefix(null);
                    if (tr.FindExactKey(LastDictIdKey))
                    {
                        _lastDictId = new ByteArrayReader(tr.GetValueAsByteArray()).ReadVUInt64();
                    }
                }
            }
        }
예제 #6
0
파일: TableInfo.cs 프로젝트: quyenbc/BTDB
 internal TableInfo(uint id, string name, ITableInfoResolver tableInfoResolver)
 {
     _id = id;
     _name = name;
     _tableInfoResolver = tableInfoResolver;
 }
예제 #7
0
파일: ObjectDB.cs 프로젝트: Bobris/BTDB
 public void Open(IKeyValueDB keyValueDB, bool dispose)
 {
     if (keyValueDB == null) throw new ArgumentNullException(nameof(keyValueDB));
     _keyValueDB = keyValueDB;
     _dispose = dispose;
     _tableInfoResolver = new TableInfoResolver(keyValueDB, this);
     _tablesInfo = new TablesInfo(_tableInfoResolver);
     _relationsInfoResolver = new RelationInfoResolver(this);
     _relationsInfo = new RelationsInfo(_relationsInfoResolver);
     _lastObjId = 0;
     using (var tr = _keyValueDB.StartTransaction())
     {
         tr.SetKeyPrefix(AllObjectsPrefix);
         if (tr.FindLastKey())
         {
             _lastObjId = (long)new KeyValueDBKeyReader(tr).ReadVUInt64();
         }
         _tablesInfo.LoadTables(LoadTablesEnum(tr));
         _relationsInfo.LoadRelations(LoadRelationNamesEnum(tr));
         tr.SetKeyPrefix(null);
         if (tr.FindExactKey(LastDictIdKey))
         {
             _lastDictId = new ByteArrayReader(tr.GetValueAsByteArray()).ReadVUInt64();
         }
     }
 }
예제 #8
0
 public TablesInfo(ITableInfoResolver tableInfoResolver)
 {
     _tableInfoResolver = tableInfoResolver;
 }
예제 #9
0
파일: TablesInfo.cs 프로젝트: quyenbc/BTDB
 public TablesInfo(ITableInfoResolver tableInfoResolver)
 {
     _tableInfoResolver = tableInfoResolver;
 }
예제 #10
0
 internal TableInfo(uint id, string name, ITableInfoResolver tableInfoResolver)
 {
     _id   = id;
     _name = name;
     _tableInfoResolver = tableInfoResolver;
 }