public static void ImportAll(string directoryName) { var namespaces = HelpLogic.AllTypes().Select(a => a.Namespace !).Distinct().ToDictionary(a => a); var types = HelpLogic.AllTypes().ToDictionary(a => a.FullName !); foreach (var path in Directory.GetFiles(directoryName, "*.help", SearchOption.AllDirectories)) { try { XDocument doc = XDocument.Load(path); ImportAction action = doc.Root !.Name == AppendixXml._Appendix ? AppendixXml.Load(doc): doc.Root !.Name == NamespaceXml._Namespace ? NamespaceXml.Load(doc, namespaces): doc.Root !.Name == EntityXml._Entity ? EntityXml.Load(doc, types): doc.Root !.Name == QueryXml._Query ? QueryXml.Load(doc) : throw new InvalidOperationException("Unknown Xml root: " + doc.Root.Name); ConsoleColor color = action == ImportAction.Inserted ? ConsoleColor.Green : action == ImportAction.Updated ? ConsoleColor.DarkGreen : action == ImportAction.Skipped ? ConsoleColor.Yellow : action == ImportAction.NoChanges ? ConsoleColor.DarkGray : throw new InvalidOperationException("Unexpected action"); SafeConsole.WriteLineColor(color, " {0} {1}".FormatWith(action, path)); } catch (Exception e) { SafeConsole.WriteLineColor(ConsoleColor.Red, " Error {0}:\r\n\t".FormatWith(path) + e.Message); } } }