public byte[] Get(uint crc, FileStorage.Type type, uint entityID)
 {
     using (TimeWarning.New("FileStorage.Get", 0.1f))
     {
         FileStorage.CacheData cacheData;
         if (this._cache.TryGetValue(crc, out cacheData))
         {
             Assert.IsTrue(cacheData.data != null, "FileStorage cache contains a null texture");
             return(cacheData.data);
         }
         if (this.db == null)
         {
             return((byte[])null);
         }
         byte[] numArray = this.db.QueryBlob("SELECT data FROM data WHERE crc = ? AND filetype = ? AND entid = ? LIMIT 1", new object[3]
         {
             (object)(int)crc,
             (object)(int)type,
             (object)(int)entityID
         });
         if (numArray == null)
         {
             return((byte[])null);
         }
         this._cache.Remove(crc);
         this._cache.Add(crc, new FileStorage.CacheData()
         {
             data     = numArray,
             entityID = entityID,
             numID    = 0U
         });
         return(numArray);
     }
 }
 public uint Store(byte[] data, FileStorage.Type type, uint entityID, uint numID = 0)
 {
     using (TimeWarning.New("FileStorage.Store", 0.1f))
     {
         uint crc = this.GetCRC(data, type);
         if (this.db != null)
         {
             this.db.Execute("INSERT OR REPLACE INTO data ( crc, data, entid, filetype, part ) VALUES ( ?, ?, ?, ?, ? )", new object[5]
             {
                 (object)(int)crc,
                 (object)data,
                 (object)(int)entityID,
                 (object)(int)type,
                 (object)(int)numID
             });
         }
         this._cache.Remove(crc);
         this._cache.Add(crc, new FileStorage.CacheData()
         {
             data     = data,
             entityID = entityID,
             numID    = numID
         });
         return(crc);
     }
 }
 private uint GetCRC(byte[] data, FileStorage.Type type)
 {
     this.crc.Reset();
     this.crc.SlurpBlock(data, 0, data.Length);
     this.crc.UpdateCRC((byte)type);
     return((uint)this.crc.get_Crc32Result());
 }
Beispiel #4
0
 public void Remove(uint crc, FileStorage.Type type, uint entityID)
 {
     using (TimeWarning timeWarning = TimeWarning.New("FileStorage.Remove", 0.1f))
     {
         if (this.db != null)
         {
             this.db.Execute("DELETE FROM data WHERE crc = ? AND filetype = ? AND entid = ?", new object[] { (int)crc, (int)type, (int)entityID });
         }
         if (this._cache.ContainsKey(crc))
         {
             this._cache.Remove(crc);
         }
     }
 }
Beispiel #5
0
 public byte[] Get(uint crc, FileStorage.Type type, uint entityID)
 {
     FileStorage.CacheData cacheDatum;
     byte[] numArray;
     using (TimeWarning timeWarning = TimeWarning.New("FileStorage.Get", 0.1f))
     {
         if (this._cache.TryGetValue(crc, out cacheDatum))
         {
             Assert.IsTrue(cacheDatum.data != null, "FileStorage cache contains a null texture");
             numArray = cacheDatum.data;
         }
         else if (this.db != null)
         {
             byte[] numArray1 = this.db.QueryBlob("SELECT data FROM data WHERE crc = ? AND filetype = ? AND entid = ? LIMIT 1", new object[] { (int)crc, (int)type, (int)entityID });
             if (numArray1 != null)
             {
                 this._cache.Remove(crc);
                 this._cache.Add(crc, new FileStorage.CacheData()
                 {
                     data     = numArray1,
                     entityID = entityID,
                     numID    = 0
                 });
                 numArray = numArray1;
             }
             else
             {
                 numArray = null;
             }
         }
         else
         {
             numArray = null;
         }
     }
     return(numArray);
 }