void RearrangeExamples(List <CodeExampleGroup> examples) { for (int i = 0; i < examples.Count; i++) { CodeExampleGroup group = examples[i]; if (group.Name == "Pivot Table Actions") { examples.RemoveAt(i); examples.Insert(0, group); break; } } }
public static List <CodeExampleGroup> FindExamples(string examplePath, Dictionary <string, FileInfo> examplesCS, Dictionary <string, FileInfo> examplesVB) { List <CodeExampleGroup> result = new List <CodeExampleGroup>(); Dictionary <string, FileInfo> current = null; ExampleFinder csExampleFinder; ExampleFinder vbExampleFinder; if (examplesCS.Count == 0) { current = examplesVB; csExampleFinder = null; vbExampleFinder = new ExampleFinderVB(); } else if (examplesVB.Count == 0) { current = examplesCS; csExampleFinder = new ExampleFinderCSharp(); vbExampleFinder = null; } else { current = examplesCS; csExampleFinder = new ExampleFinderCSharp(); vbExampleFinder = new ExampleFinderVB(); } foreach (KeyValuePair <string, FileInfo> sourceCodeItem in current) { string key = sourceCodeItem.Key; List <CodeExample> foundExamplesCS = new List <CodeExample>(); if (csExampleFinder != null) { foundExamplesCS = csExampleFinder.Process(examplesCS[key]); } List <CodeExample> foundExamplesVB = new List <CodeExample>(); if (vbExampleFinder != null) { foundExamplesVB = vbExampleFinder.Process(examplesVB[key]); } List <CodeExample> mergedExamples = new List <CodeExample>(); if (foundExamplesCS.Count != 0 && foundExamplesVB.Count == 0) { mergedExamples = foundExamplesCS; } else if (foundExamplesCS.Count == 0 && foundExamplesVB.Count != 0) { mergedExamples = foundExamplesVB; } else if ((foundExamplesCS.Count == foundExamplesVB.Count)) { mergedExamples = MergeExamples(foundExamplesCS, foundExamplesVB); } if (mergedExamples.Count == 0) { continue; } CodeExampleGroup group = new CodeExampleGroup() { Name = mergedExamples[0].HumanReadableGroupName, Examples = mergedExamples }; result.Add(group); } return(result); }
internal void Merge(CodeExampleGroup n) { this.Examples.AddRange(n.Examples); }