public void MergeEntryTo(HelpDescription helpDescription, Entry entry) { var pageGroups = events.GroupBy(e => e.Page); foreach (var pageGroup in pageGroups) { var page = helpDescription.Pages.FirstOrDefault(p => p.Path == pageGroup.Key); if (page == null) { page = new Page {Path = pageGroup.Key}; helpDescription.Pages.Add(page); } var scopeGroups = pageGroup.GroupBy(e => new {e.ScopeType, e.ScopeKey}); bool hasNonNavigate = scopeGroups.Any(sg => sg.Key.ScopeType != ScopeType.Navigate); if (hasNonNavigate) scopeGroups = scopeGroups.Where(sg => sg.Key.ScopeType != ScopeType.Navigate); foreach (var scopeGroup in scopeGroups) { var scope = page.Scopes.FirstOrDefault(s => s.Type == scopeGroup.Key.ScopeType && s.Key == scopeGroup.Key.ScopeKey); if (scope == null) { scope = new Scope {Type = scopeGroup.Key.ScopeType, Key = scopeGroup.Key.ScopeKey}; page.Scopes.Add(scope); } scope.Entries.Add(entry); } } }
public static void Init() { helpDescription = new HelpDescription(); }
public void SaveTo(HelpDescription helpDescription, string filePath) { var serizlizer = new XmlSerializer(typeof(HelpDescription)); using(var fileStream = new FileStream(filePath, FileMode.Create)) { serizlizer.Serialize(fileStream, helpDescription); } }