// Token: 0x06000127 RID: 295 RVA: 0x00009D74 File Offset: 0x00007F74 public void Write(bool writeAlways) { if (!writeAlways && !this._isDirty) { return; } if (FileUtil2.Exists(this._cachePath)) { if (FileUtil2.IsReadOnly(this._cachePath)) { this.ShowCacheFileReadOnlyMessage(true); } if (FileUtil2.IsReadOnly(this._cachePath)) { return; } } using (MemoryStream memoryStream = new MemoryStream(1048576)) { using (BinaryWriter binaryWriter = new BinaryWriter(memoryStream)) { binaryWriter.Write(322416638u); binaryWriter.Write(this._fileVersion); List <T> list = new List <T>(this._lut.Values); binaryWriter.Write(list.Count); BinarySerializer data = new BinarySerializer(binaryWriter); foreach (T t in list) { t.Serialize(data); } } File.WriteAllBytes(this._cachePath, memoryStream.ToArray()); this._isDirty = false; } }
// Token: 0x06000124 RID: 292 RVA: 0x00009B30 File Offset: 0x00007D30 public void Read() { this._isDirty = false; this._lut = new Dictionary <string, T>(); try { if (FileUtil2.Exists(this._cachePath)) { if (FileUtil2.IsReadOnly(this._cachePath)) { this.ShowCacheFileReadOnlyMessage(false); } using (MemoryStream memoryStream = new MemoryStream(File.ReadAllBytes(this._cachePath))) { using (BinaryReader binaryReader = new BinaryReader(memoryStream)) { uint num = binaryReader.ReadUInt32(); if (num != 322416638u) { Debug.Log(string.Format("{0}: Cache file '{1}' contains an invalid header magic.", this._appTitle, this._cachePath)); } else { int num2 = binaryReader.ReadInt32(); if ((long)num2 != (long)((ulong)this._fileVersion)) { Debug.Log(string.Format("{0}: Incompatible cache file detected, generating new one. ('{1}').\nThe most likely reason is you upgraded the plugin to a newer version. Existing cache file version is '{2}', required version is '{3}'.", new object[] { this._appTitle, this._cachePath, num2, this._fileVersion })); } else { BinarySerializer data = new BinarySerializer(binaryReader); int num3 = binaryReader.ReadInt32(); for (int i = 0; i < num3; i++) { T value = (default(T) == null) ? Activator.CreateInstance <T>() : default(T); value.Serialize(data); string assetGuid = value.GetAssetGuid(); this._lut[assetGuid] = value; } } } } } } } catch (Exception ex) { Debug.LogError(string.Format("{0}: Could not read cache file '{1}'.\n{2}", this._appTitle, this._cachePath, ex.ToString())); } }