Ejemplo n.º 1
0
        internal ObjectKey ReadKey(long position, int length)
        {
            byte[] buffer = new byte[this.keysLength];
            this.ReadBuffer(buffer, position, length);
            MemoryStream input     = new MemoryStream(buffer);
            BinaryReader reader    = new BinaryReader(input);
            ObjectKey    objectKey = new ObjectKey(this, null, null);

            objectKey.Read(reader, true);
            objectKey.position = position;
            return(objectKey);
        }
Ejemplo n.º 2
0
 private void WriteFree()
 {
     if (this.freeListKey != null)
     {
         this.DeleteKey(this.freeListKey, false);
     }
     this.freeListKey = new ObjectKey(this, "FreeKeys", new FreeKeyList(this.free));
     this.freeListKey.compressionLevel = 0;
     this.WriteKey(this.freeListKey);
     this.freePosition = this.freeListKey.position;
     this.freeLength   = this.freeListKey.keyLength + this.freeListKey.objLength;
 }
Ejemplo n.º 3
0
 private void ReadCache()
 {
     this.cacheKey = this.file.ReadKey(this.cachePosition, 38);
     this.cache    = ((DataKeyIdArray)this.cacheKey.GetObject()).keys;
     for (int i = 0; i < this.cache.Size; i++)
     {
         if (this.cache[i] != null)
         {
             this.cache[i].file   = this.file;
             this.cache[i].number = i;
         }
     }
 }
Ejemplo n.º 4
0
        public override object Read(BinaryReader reader)
        {
            Dictionary <string, ObjectKey> dictionary = new Dictionary <string, ObjectKey>();

            reader.ReadByte();
            int num = reader.ReadInt32();

            for (int i = 0; i < num; i++)
            {
                ObjectKey objectKey = new ObjectKey();
                objectKey.Read(reader, true);
                dictionary.Add(objectKey.name, objectKey);
            }
            return(new ObjectKeyList(dictionary));
        }
Ejemplo n.º 5
0
 internal void WriteKey(ObjectKey key)
 {
     this.stream_.SetLength(0L);
     key.Write(this.writer_);
     if (key.position != -1L)
     {
         if (this.stream_.Length > (long)key.recLength)
         {
             this.DeleteKey(key, false);
             key.recLength = (int)this.stream_.Length;
             FreeKey freeKey;
             if (key == this.freeListKey)
             {
                 freeKey = this.GetFree(key.keyLength + key.objLength - 17);
             }
             else
             {
                 freeKey = this.GetFree(key.keyLength + key.objLength);
             }
             if (freeKey != null)
             {
                 key.position  = freeKey.position;
                 key.recLength = freeKey.length;
                 this.free.Remove(freeKey);
                 this.freeNumber--;
                 if (key == this.freeListKey)
                 {
                     this.stream_.SetLength(0L);
                     key.Write(this.writer_);
                 }
             }
             else
             {
                 key.position      = this.endPosition;
                 this.endPosition += (long)key.recLength;
             }
         }
     }
     else
     {
         key.position      = this.endPosition;
         this.endPosition += (long)key.recLength;
     }
     this.WriteBuffer(this.stream_.GetBuffer(), key.position, (int)this.stream_.Length);
     key.changed     = false;
     this.isModified = true;
 }
Ejemplo n.º 6
0
        protected void ReadFree()
        {
            if (this.freeLength == 0)
            {
                return;
            }
            byte[] buffer = new byte[this.freeLength];
            this.ReadBuffer(buffer, this.freePosition, this.freeLength);
            MemoryStream input     = new MemoryStream(buffer);
            BinaryReader reader    = new BinaryReader(input);
            ObjectKey    objectKey = new ObjectKey(this, null, null);

            objectKey.Read(reader, true);
            objectKey.position = this.freePosition;
            this.free          = ((FreeKeyList)objectKey.GetObject()).keys;
            this.freeListKey   = objectKey;
        }
Ejemplo n.º 7
0
 internal void DeleteKey(ObjectKey key, bool remove = true)
 {
     key.deleted = true;
     this.WriteBuffer(new byte[]
     {
         1
     }, key.position + 5L, 1);
     if (remove)
     {
         this.keys.Remove(key.name);
         this.keysNumber--;
     }
     this.free.Add(new FreeKey(key));
     this.free.Sort();
     this.freeNumber++;
     this.isModified = true;
 }
Ejemplo n.º 8
0
 internal void Init(DataFile file, ObjectKey key)
 {
     this.file             = file;
     this.key              = key;
     key.compressionLevel  = 0;
     key.compressionMethod = 0;
     if (this.cachePosition == -1L)
     {
         if (this.buffer_count < 4096)
         {
             this.cache = new IdArray <DataKey>(4096);
         }
         else
         {
             this.cache = new IdArray <DataKey>(this.buffer_count);
         }
         this.cacheKey = new ObjectKey(file, "", new DataKeyIdArray(this.cache));
     }
 }
Ejemplo n.º 9
0
        protected void ReadKeys()
        {
            if (this.keysLength == 0)
            {
                return;
            }
            byte[] buffer = new byte[this.keysLength];
            this.ReadBuffer(buffer, this.keysPosition, this.keysLength);
            MemoryStream input     = new MemoryStream(buffer);
            BinaryReader reader    = new BinaryReader(input);
            ObjectKey    objectKey = new ObjectKey(this, null, null);

            objectKey.Read(reader, true);
            objectKey.position = this.keysPosition;
            this.keys          = ((ObjectKeyList)objectKey.GetObject()).keys;
            foreach (ObjectKey current in this.keys.Values)
            {
                current.Init(this);
            }
            this.keysListKey = objectKey;
        }
Ejemplo n.º 10
0
        public void Write(string name, object obj)
        {
            ObjectKey objectKey;

            this.keys.TryGetValue(name, out objectKey);
            if (objectKey != null)
            {
                objectKey.obj = obj;
                objectKey.Init(this);
            }
            else
            {
                objectKey = new ObjectKey(this, name, obj);
                this.keys.Add(name, objectKey);
                this.keysNumber++;
            }
            objectKey.dateTime = DateTime.Now;
            if (objectKey.typeId == 101)
            {
                ((DataSeries)obj).Init(this, objectKey);
            }
            this.WriteKey(objectKey);
        }
Ejemplo n.º 11
0
 public FreeKey(ObjectKey key)
 {
     this.file     = key.file;
     this.position = key.position;
     this.length   = key.recLength;
 }