コード例 #1
0
        private static void OnTest(object obj)
        {
            Testing t = obj as Testing;
            IEnumerable <KeyValuePair <string, ContentInfo> > tmp = t.Data;

            var listIgnore         = new SortedList <string, int>();
            var listWithDuplicates = new SortedList <string, EpisodeInfo>();

            foreach (KeyValuePair <string, ContentInfo> ci in tmp)
            {
                string name;
                int    seasonNr, episodeNr;
                string filename = ci.Value.Get(ContentInfo.VIRTUAL);
                if (Ignore.TryAddIgnore(filename, out name))
                {
                    if (!listIgnore.ContainsKey(name))
                    {
                        listIgnore.Add(name, 0);
                    }
                }
                else if (Service.TryGetSerie(filename, out name, out seasonNr, out episodeNr))
                {
                    int version = seasonNr = (seasonNr * 100) + episodeNr;

                    EpisodeInfo ep = new EpisodeInfo();
                    ep.Version     = version;
                    ep.RawFileName = filename;

                    if (!listWithDuplicates.ContainsKey(name))
                    {
                        listWithDuplicates.Add(name, ep);
                    }
                    else
                    {
                        EpisodeInfo tmpEp = listWithDuplicates[name];
                        if (tmpEp.Version < version)
                        {
                            listWithDuplicates.Remove(name);
                            listWithDuplicates.Add(name, ep);
                        }
                    }
                }
            }
            //if (listIgnore.Count != 0)
            t.IgnoreList = listIgnore;
            //if (listWithDuplicates.Count != 0)
            t.DuplicatesList = listWithDuplicates;
            t.Progress       = 1;
        }