コード例 #1
0
 public TrackDanceInfo(Dance dance, DanceCategories categories, uint?rawRating = null, DanceDifficulty difficulty = DanceDifficulty.Any, DanceReviewStatus status = DanceReviewStatus.NeedsReview)
 {
     Dance      = dance;
     Categories = categories;
     Difficulty = difficulty;
     RawRating  = rawRating;
     Status     = status;
 }
コード例 #2
0
        public DanceInfoTagParser(uint?defaultRating, DanceCategories defaultCategories, IEnumerable <string> tags)
        {
            DefaultRating     = defaultRating;
            DefaultCategories = defaultCategories;

            UnusedTags = tags.Select <string, string>(ExtractTag).Where((s) => !String.IsNullOrEmpty(s)).ToList().AsReadOnly();

            UpdateAllCategories();
            Dances = RatingsByDance.Keys.ToList();
        }
コード例 #3
0
        protected void UpdateAllCategories()
        {
            var all = DanceCategories.None;

            foreach (var kvp in CategoriesByRating)
            {
                if ((all & kvp.Value) != 0)
                {
                    throw new ApplicationException($"Multiple ratings for {kvp.Value}");
                }
                all |= kvp.Value;
            }

            if (UnratedCategories != DanceCategories.None)
            {
                UnratedCategories &= ~all;
            }

            Categories = all | UnratedCategories;
        }
コード例 #4
0
        protected void AddOrUpdateCategories(DanceCategories categories, uint?rating)
        {
            DanceCategories existing;

            if (!rating.HasValue)
            {
                UnratedCategories |= categories;
            }
            else
            {
                if (CategoriesByRating.TryGetValue(rating.Value, out existing))
                {
                    var newCategories = categories | existing;
                    CategoriesByRating[rating.Value] = newCategories;
                }
                else
                {
                    CategoriesByRating[rating.Value] = categories;
                }
            }
        }
コード例 #5
0
        public Dance(string[] names, IEnumerable <TempoRange> tempos)
        {
            if ((names == null) || (names.Length < 1))
            {
                throw new ApplicationException("Dance constructor needs at least one name");
            }

            Name         = names[0];
            AllNames     = names;
            Abbreviation = names.First((n) => n.Length == 3) ?? Name.Substring(0, 3).ToUpperInvariant();

            foreach (var tempo in tempos)
            {
                var flag = (DanceCategories)(1 << (int)tempo.Category);
                if ((Categories & flag) != 0)
                {
                    throw new ApplicationException($"Tempos for {tempo.Category} specified multiple times for {Name}");
                }
                Categories |= flag;
                _tempos[tempo.Category] = tempo;
            }
        }
コード例 #6
0
 public static IEnumerable <DanceCategory> EnumerateCategories(DanceCategories categories)
 {
     return(AllCategories.Where((c) => (categories & ((DanceCategories)(1 << (int)c))) != 0));
 }
コード例 #7
0
 protected bool TryGetCategoryMask(string tag, out DanceCategories mask)
 {
     return(Enum.TryParse <DanceCategories>(tag, true, out mask));
 }
コード例 #8
0
 public DanceInfoTagParser(uint?defaultRating, DanceCategories defaultCategories, params string[] tags)
     : this(defaultRating, defaultCategories, (IEnumerable <string>)tags)
 {
 }