public void addItem(String item) { if (Items.Contains(item)) { return; } Items.Add(item); AutoCompleteItems.Add(new AutoCompleteEntry(item, item)); }
static void Main(string[] args) { AutoCompleteItems items = new AutoCompleteItems(); HashSet <string> completed = new HashSet <string>(); int KeywordLinksCount = HelpContext.Reader.Index.Count(HtmlHelp.IndexType.KeywordLinks); for (int i = 0; i < KeywordLinksCount; i++) { HtmlHelp.IndexItem indexItem = (HtmlHelp.IndexItem)HelpContext.Reader.Index.KLinks[i]; foreach (HtmlHelp.IndexTopic topic in indexItem.Topics) { string title = topic.Title.Replace(" :: ", ".").Trim(); if (completed.Contains(title) == false) { string fileContents = topic.FileContents; int startPos = fileContents.IndexOf("<!-- ##BEGIN_DESCRIPTION## -->"); if (startPos > 0) { startPos += 31; int endPos = fileContents.IndexOf("<!-- ##END_DESCRIPTION## -->", startPos); if (endPos > 0) { string typelessName = title; foreach (string typeName in types) { typelessName = typelessName.Replace(typeName + ".", ""); } completed.Add(title); items.Add(new AutoCompleteItem { Topic = title, Keyword = title.ToLower(), URL = topic.Local.Trim(), Content = fileContents.Substring(startPos, endPos - startPos).Trim(), }); if (typelessName != title) { completed.Add(typelessName); items.Add(new AutoCompleteItem { Type = title.Replace(typelessName, "").Trim('.'), Topic = typelessName, Keyword = typelessName.ToLower(), URL = topic.Local.Trim(), Content = fileContents.Substring(startPos, endPos - startPos).Trim(), }); } } } } } } string json = JsonConvert.SerializeObject(items); System.IO.File.WriteAllText("..\\..\\..\\..\\Documentation\\AutoComplete.json", json); }