/// <summary> /// Vrátí zdroj daného jména, nebo null. /// </summary> /// <param name="resourceKey"></param> /// <returns></returns> private ResourceItem SearchForResource(string resourceKey) { string key = ResourceItem.GetKey(resourceKey); ResourceItem resourceItem; if (this._ResourceDict.TryGetValue(key, out resourceItem)) { return(resourceItem); } return(null); }
/// <summary> /// Metoda fyzicky načte obsah dodaného souboru (resourceFile) /// </summary> /// <param name="resourceFile"></param> /// <returns></returns> private Dictionary <string, ResourceItem> _ReadResourceContent(string resourceFile) { Dictionary <string, ResourceItem> result = new Dictionary <string, ResourceItem>(); // byte[] resourceContent = System.IO.File.ReadAllBytes(resourceFile); //using (System.IO.Stream resourceStream = new System.IO.MemoryStream(resourceContent)) try { using (System.IO.Stream resourceStream = new System.IO.FileStream(resourceFile, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read)) using (System.IO.Compression.ZipArchive zip = new System.IO.Compression.ZipArchive(resourceStream, System.IO.Compression.ZipArchiveMode.Read)) { foreach (var entry in zip.Entries) { if (entry.Length > 0) { string key = ResourceItem.GetKey(entry.FullName); if (!result.ContainsKey(key)) { using (var entryStream = entry.Open()) using (System.IO.MemoryStream entryContent = new System.IO.MemoryStream()) { entryStream.CopyTo(entryContent); result.Add(key, new ResourceItem(key, entryContent.ToArray())); } } } } } } catch (Exception exc) { App.Trace.Exception(exc); } return(result); }