/// <summary> /// Gets the source code stream. /// </summary> /// <returns></returns> public MemoryStream GetSourceCodeStream() { if (m_Items.Count == 0) { return(null); } else if (m_Items.Count == 1) { return((MemoryStream)m_Items[0].Stream); } // Analyze the example names and returns the best matching one NZipItem bestItem = null; int bestScore = -1; string[] tokens = m_ExampleNamespace.Split('.'); for (int i = 0; i < m_Items.Count; i++) { NZipItem item = m_Items[i]; // Find how many tokens from the namespace are present in the current file name string dirName = NPath.GetFullDirectoryName(m_Items[i].Name); int score = 0; for (int j = 0; j < tokens.Length; j++) { if (dirName.Contains(tokens[j])) { score++; } } if (score > bestScore) { // The current item is a better match, so store it bestItem = item; bestScore = score; } } return((MemoryStream)bestItem.Stream); }
public void OnItemDecompressed(NZipItem item) { string[] partNames = item.Name.Split(PathDelimitersCharArray, StringSplitOptions.RemoveEmptyEntries); // Add the folders to the tree view NTreeViewItemCollection items = m_TreeView.Items; for (int i = 0, partNameCount = partNames.Length - 1; i < partNameCount; i++) { string partName = partNames[i]; NTreeViewItem treeViewItem = GetItemByName(items, partName); if (treeViewItem == null) { // An item with the current entry name does not exist, so create it treeViewItem = AddFolder(items, partName); } items = treeViewItem.Items; } // Add the file AddFile(items, partNames[partNames.Length - 1]); }
public void OnItemDecompressed(NZipItem zipItem) { byte[] bytes = NStreamHelpers.ReadToEnd(zipItem.Stream); m_ImageMap.Add(zipItem.Name, bytes); }
public bool Filter(NZipItem item) { return(item.Name.EndsWith(".emf", StringComparison.OrdinalIgnoreCase)); }
public void OnItemDecompressed(NZipItem item) { m_Items.Add(item); }
public bool Filter(NZipItem item) { string fileName = NPath.GetFileName(item.Name); return(String.Equals(fileName, m_ExampleFileName, StringComparison.OrdinalIgnoreCase)); }
public bool Filter(NZipItem item) { return(true); }