private void updateLocalData(MangaAnimeItems locals, MangaAnimeItems remote, ref int added, ref int updated) { foreach (MangaAnimeItem remoteItem in remote.Values) { if (!locals.ContainsKey(remoteItem.id)) { locals.Add(remoteItem.id, remoteItem); added++; continue; } bool changed = false; MangaAnimeItem localItem = locals[remoteItem.id]; if (!localItem.EqualsImageUrl(remoteItem)) { localItem.url = remoteItem.url; changed = true; } if (localItem.name != remoteItem.name) { localItem.name = remoteItem.name; changed = true; } if (changed) { updated++; } } }
private MangaAnimeItems parseCssFile(StreamReader reader) { MangaAnimeItems list = new MangaAnimeItems(); string line; while ((line = reader.ReadLine()) != null) { Regex regexId = new Regex(@"#more([0-9]+)"); Regex regexUrl = new Regex(@"url\((.*)\);"); Regex regexName = new Regex(@"(\/\*.*\*\/)"); Match matchId = regexId.Match(line); Match matchUrl = regexUrl.Match(line); Match matchName = regexName.Match(line); if (!matchId.Success || !matchUrl.Success || !matchName.Success) { continue; } int id = Int32.Parse(matchId.Groups[1].Value); MangaAnimeItem item = null; if (list.ContainsKey(id)) { item = list[id]; } else { item = new MangaAnimeItem(); list.Add(id, item); } item.id = id; item.url = matchUrl.Groups[1].Value; item.name = matchName.Groups[1].Value.Substring(3).TrimEnd('/').TrimEnd('*').TrimEnd(' '); } return(list); }