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; }
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(); }
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; }
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; } } }
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; } }
public static IEnumerable <DanceCategory> EnumerateCategories(DanceCategories categories) { return(AllCategories.Where((c) => (categories & ((DanceCategories)(1 << (int)c))) != 0)); }
protected bool TryGetCategoryMask(string tag, out DanceCategories mask) { return(Enum.TryParse <DanceCategories>(tag, true, out mask)); }
public DanceInfoTagParser(uint?defaultRating, DanceCategories defaultCategories, params string[] tags) : this(defaultRating, defaultCategories, (IEnumerable <string>)tags) { }