internal List <GameContainer> MakeList(string collection, string ignorePath) { string path = Path.Combine(Directory.GetCurrentDirectory(), collection); var games = Directory.GetFiles(path) .Where(f => f.EndsWith(".xml", StringComparison.OrdinalIgnoreCase)) .Select(f => XDocument.Load(f)) .SelectMany(xdoc => XMLConverter.FromXML(xdoc)); GeekItemComparer cmp = new GeekItemComparer(); var ignoredGames = File.Exists(ignorePath) ? XMLConverter.FromXML(XDocument.Load(ignorePath)) : new List <IGeekItem>(); var marked = games .GroupBy(g => g, cmp) .Select(grp => new GameContainer { Game = grp.First().Game, Count = grp.Count(), Ignored = ignoredGames.Contains(grp.First(), cmp) }) .OrderByDescending(g => g.Count); var filtered = trueIgnore ? marked.Where(g => !g.Ignored) : marked; var result = filtered.Skip(from).Take(to - from); return(result.ToList()); }
public void Execute(IState state) { IGeekItem newItem = new GeekItem { Game = new Game { Id = gameId, Name = string.Empty } }; List <IGeekItem> gameList; string path = state.IgnorePath; gameList = File.Exists(path) ? XMLConverter.FromXML(XDocument.Load(path)) : new List <IGeekItem>(); gameList.Add(newItem); XDocument xml = XMLConverter.ToXML(gameList); xml.Save(path); }