Beispiel #1
0
 public void Load()
 {
     using (EntityReader <T> curReader = new EntityReader <T>(new MemoryStream(data), DBM))
     {
         for (int i = 1; i <= curReader.TotalRecords; i++)
         {
             //nincs double check, mert kevés az az eset amikor nem kellene lockolni (1. ág)
             lock (this.reader)
             {
                 if (array[i - 1] != null)
                 {
                     curReader.SkipRecord();
                 }
                 else
                 {
                     array[i - 1] = curReader.ReadRecord();
                 }
             }
         }
     }
     lock (this.reader)
     {
         this.reader.Close();
         this.reader = null;
         this.data   = null; //free unused memory
     }
     Loaded.Start();
 }
Beispiel #2
0
 public override IEntity Get(int index)
 {
     lock (reader)
     {
         return(reader.ReadRecord(index));
     }
 }
Beispiel #3
0
 public override IEntity Get(int i)
 {
     lock (cache)
     {
         if (fullLoaded || cache.Keys.Contains(i))
         {
             return(cache[i]);
         }
         else
         {
             T entity = reader.ReadRecord(i);
             cache.Add(i, entity);
             return(entity);
         }
     }
 }
Beispiel #4
0
 public override IEntity Get(int index)
 {
     if (array[index - 1] != null)
     {
         return(array[index - 1]);
     }
     else
     {
         //double check minta: optimális konkurencia-kezelés
         lock (reader)
         {
             if (array[index - 1] == null)
             {
                 T entity = reader.ReadRecord(index);
                 array[index - 1] = entity;
                 return(entity);
             }
             else
             {
                 return(array[index - 1]);
             }
         }
     }
 }