private void GetWeekInformationTotalPoint(Ranking ranking) { List <WeekInformation> weekInfoMatchOfficial = ranking.WeekInformation.Where(x => x.MatchInformation.Officially).ToList(); List <WeekInformation> weekInfoMatchInformal = ranking.WeekInformation.Where(x => !x.MatchInformation.Officially).ToList(); WeekInformation weekInfoTotalOfficial = new WeekInformation(99, "Total (Officially)", new List <DayInformation>()); WeekInformation weekInfoTotalInformal = new WeekInformation(98, "Total (Informal)", new List <DayInformation>()); WeekInformation weekInfo = ranking.WeekInformation.Where(x => x.DayOfWeek == 2).FirstOrDefault(); foreach (var dayInformation in weekInfo.DayInformation) { weekInfoTotalOfficial.DayInformation.Add(GetTotalPointOfPlayer(weekInfoMatchOfficial, dayInformation)); weekInfoTotalInformal.DayInformation.Add(GetTotalPointOfPlayer(weekInfoMatchInformal, dayInformation)); } ; ranking.WeekInformation.Add(weekInfoTotalOfficial); ranking.WeekInformation.Add(weekInfoTotalInformal); }
internal CourseContent(string courseName, DayOfWeek dayOfWeek, CourseTime courseTime, bool isLongCourse, bool isLab, string weekExpression) { CourseName = courseName; DayOfWeek = dayOfWeek; CourseTime = courseTime; IsLongCourse = isLongCourse; IsLab = isLab; //Parse Week Expression weekExpression = ResourceProvider.Resource.RemoveCommaSpace(weekExpression); var currentTeacher = ""; var timeStack = new Stack <string>(); var timeTeacherMap = new Dictionary <string, string>(); var timeLocationMap = new Dictionary <string, string>(); foreach (var match in ResourceProvider.Resource.ScheduleExpressionUnitRegex.Matches(weekExpression)) { var unit = match?.ToString(); if (unit == null) { continue; } var unitType = ResourceProvider.Resource.LocationRegex.IsMatch(unit) ? ScheduleExpressionUnitType.Location : ResourceProvider.Resource.TeacherNameRegex.IsMatch(unit) ? ScheduleExpressionUnitType.Teacher : ResourceProvider.Resource.CourseTimeRegex.IsMatch(unit) ? ScheduleExpressionUnitType.Time : ScheduleExpressionUnitType.Unknown; switch (unitType) { case ScheduleExpressionUnitType.Teacher: currentTeacher = unit; break; case ScheduleExpressionUnitType.Time: timeTeacherMap.Add(unit, currentTeacher); timeStack.Push(unit); break; case ScheduleExpressionUnitType.Location: while (timeStack.Count > 0) { timeLocationMap.Add(timeStack.Pop(), unit); } break; case ScheduleExpressionUnitType.Unknown: throw new ArgumentException(weekExpression, nameof(weekExpression), null); default: throw new ArgumentOutOfRangeException(); } } while (timeStack.Count > 0) { timeLocationMap.Add(timeStack.Pop(), "<地点待定>"); } foreach (var time in timeTeacherMap.Keys) { foreach (var weekIndex in ResourceProvider.Resource.ToIntSequence(time)) { WeekInformation.Add(weekIndex, new() { Name = CourseName, Teacher = timeTeacherMap[time], Location = timeLocationMap[time] }); } } }