Ejemplo n.º 1
0
 public void CopyTo(IdArray <T> array)
 {
     for (int i = 0; i < array.Size; i++)
     {
         array[i] = i < Size ? this.array[i] : default(T);
     }
 }
Ejemplo n.º 2
0
        public GetByList(string idPropName, string namePropName, int size = 1024)
        {
            var t = typeof(T);

            this.idMethod   = t.GetProperty(idPropName).GetMethod;
            this.nameMethod = t.GetProperty(namePropName).GetMethod;
            this.dictionary = new Dictionary <string, T>();
            this.array      = new IdArray <T>(size);
            this.list       = new List <T>();
        }
Ejemplo n.º 3
0
 internal void OpenRead()
 {
     lock (Sync)
     {
         if (this.readOpened)
         {
             Console.WriteLine("DataSeries::OpenRead already read open");
             return;
         }
         this.cache      = this.cache ?? ReadCache();
         this.readOpened = true;
     }
 }
Ejemplo n.º 4
0
        internal void Init(DataFile file, ObjectKey key)
        {
            lock (Sync)
            {
                this.file             = file;
                this.key              = key;
                key.CompressionLevel  = 0;
                key.CompressionMethod = 0;

                // Init dataKey list
                if (this.cachePosition == -1)
                {
                    this.cache    = new IdArray <DataKey>(Math.Max(4096, this.bufferCount));
                    this.cacheKey = new ObjectKey(file, "", new DataKeyIdArray(this.cache));
                }
            }
        }
Ejemplo n.º 5
0
        internal void OpenWrite()
        {
            lock (Sync)
            {
                if (this.writeOpened)
                {
                    Console.WriteLine("DataSeries::OpenWrite already write open");
                    return;
                }
                this.cache = this.cache ?? ReadCache();

                if (this.bufferCount != 0 && this.cache[this.bufferCount - 1] != null)
                {
                    this.writeKey = this.cache[this.bufferCount - 1];
                    this.writeKey.GetObjects();
                }
                else
                {
                    if (this.position2 != -1)
                    {
                        this.writeKey        = ReadKey(this.position2);
                        this.writeKey.number = this.bufferCount - 1;
                        this.writeKey.GetObjects();
                    }
                    else
                    {
                        this.writeKey = new DataKey(this.file)
                        {
                            number  = 0,
                            changed = true
                        };
                        this.bufferCount = 1;
                    }
                    this.cache[this.writeKey.number] = this.writeKey;
                }
                if (this.cacheKey.position != -1)
                {
                    this.file.DeleteKey(this.cacheKey, false, false);
                }

                this.cachePosition = -1;
                this.file.WriteKey(this.key);
                this.writeOpened = true;
            }
        }
Ejemplo n.º 6
0
        public static object FromReader(BinaryReader reader, byte version)
        {
            int size = reader.ReadInt32();
            var keys = new IdArray <DataKey>(size);

            while (true)
            {
                int index = reader.ReadInt32();
                if (index == -1)
                {
                    break;
                }
                var key = new DataKey(null, null, -1, -1);
                key.Read(reader, true);
                keys.Add(index, key);
            }
            return(new DataKeyIdArray(keys));
        }
Ejemplo n.º 7
0
 public void Clear()
 {
     lock (Sync)
     {
         this.cache = this.cache ?? ReadCache();
         if (this.position1 != -1)
         {
             var key = ReadKey(this.position1);
             while (true)
             {
                 this.file.DeleteKey(key, false, true);
                 if (key.next == -1)
                 {
                     break;
                 }
                 key = ReadKey(key.next);
             }
         }
         Count             = 0;
         this.bufferCount  = 0;
         DateTime1         = new DateTime(0);
         DateTime2         = new DateTime(0);
         this.position1    = -1;
         this.position2    = -1;
         this.readOpened   = false;
         this.writeOpened  = false;
         this.cache        = new IdArray <DataKey>(4096);
         this.cacheKey.obj = new DataKeyIdArray(this.cache);
         this.readKey      = null;
         this.writeKey     = null;
         this.deleteKey    = null;
         this.insertKey    = null;
         this.changed      = true;
         Flush();
     }
 }
Ejemplo n.º 8
0
 public DataKeyIdArray(IdArray <DataKey> keys)
 {
     Keys = keys;
 }