Example #1
0
        public static Nintendo3DSTitle[] FilterTitles(Nintendo3DSTitle[] titles, TitleFilter filter)
        {
            var includedRegions = filter.RegionFilter.Where(a => a.Value).ToDictionary(a => a.Key, a => a.Value);
            var includedTypes   = filter.TypeFilter.Where(a => a.Value).ToDictionary(a => a.Key, a => a.Value);

            var shouldAddUnknown = filter.OtherFilter["Unknown"];

            var filtered = new List <Nintendo3DSTitle>();

            foreach (var title in titles)
            {
                var validType = includedTypes.Any(pair => title.Type.Contains(pair.Key));

                if (shouldAddUnknown && title.Name == "Unknown")
                {
                    if (validType)
                    {
                        filtered.Add(title);
                    }
                }
                else
                {
                    var validRegion = includedRegions.Where(pair => pair.Value).Any(pair => title.Region == pair.Key);
                    if (validRegion && validType)
                    {
                        filtered.Add(title);
                    }
                }
            }

            return(filtered.ToArray());
        }
Example #2
0
        public TitleFilter Clone()
        {
            var newRegionFilter = this.RegionFilter.ToDictionary(e => e.Key, e => e.Value);
            var newTypeFilter   = this.TypeFilter.ToDictionary(e => e.Key, e => e.Value);
            var newOtherFilter  = this.OtherFilter.ToDictionary(e => e.Key, e => e.Value);

            var newFilter = new TitleFilter(newRegionFilter, newTypeFilter, newOtherFilter);

            return(newFilter);
        }
Example #3
0
        public static void WriteFilterSettings(TitleFilter filter, string filterPath)
        {
            var output = JsonPrettifier.FormatJson(JsonConvert.SerializeObject(filter));

            File.WriteAllText(filterPath, output);
        }
Example #4
0
        public static void WriteFilterSettings(TitleFilter filter, string filterPath)
        {
            var output = JsonConvert.SerializeObject(filter, Formatting.Indented);

            File.WriteAllText(filterPath, output);
        }
Example #5
0
 protected bool Equals(TitleFilter other)
 {
     return(Equals(this.RegionFilter, other.RegionFilter) && Equals(this.TypeFilter, other.TypeFilter) && Equals(this.OtherFilter, other.OtherFilter));
 }