Dictionary <string, TileSet> LoadTileSets(Dictionary <string, TileSet> itemCache, Dictionary <string, SequenceCache> sequenceCaches, string[] files) { var items = new Dictionary <string, TileSet>(); foreach (var file in files) { TileSet t; if (itemCache.TryGetValue(file, out t)) { items.Add(t.Id, t); } else { t = new TileSet(modData, file); itemCache.Add(file, t); // every time we load a tile set, we create a sequence cache for it var sc = new SequenceCache(modData, t); sequenceCaches.Add(t.Id, sc); items.Add(t.Id, t); } } return(items); }
/// <summary> /// Disposes the underlying stream. /// </summary> /// <param name="disposing">Flag to indicate whether disposing or not.</param> protected virtual void Dispose(bool disposing) { this.Close(); if (disposing) { this.buffer = null; this.sequenceCache = null; this.SequencesCached = false; } }
/// <summary> /// Disposes the underlying stream. /// </summary> /// <param name="disposing">Flag to indicate whether disposing or not.</param> protected virtual void Dispose(bool disposing) { if (disposing) { if (this.stream != null) { this.stream.Dispose(); this.stream = null; } this.sequenceCache = null; this.SequencesCached = false; } }
/// <summary> /// Loads sequences to cache. /// This method will ignore the call if sequences are already cached. /// </summary> public void CacheSequencesForRandomAccess() { if (this.SequencesCached) { return; } this.sequenceCache = new SequenceCache(); foreach (ISequence sequence in this.Parse()) { long position = long.Parse(sequence.ID.Substring(sequence.ID.LastIndexOf('@') + 1), CultureInfo.InvariantCulture); this.sequenceCache.Add(position, sequence); } if (this.sequenceCache.Count > 0) { this.SequencesCached = true; } }