Exemplo n.º 1
0
        private static RatingScopeCollection ConvertToScopes(Dictionary <string, StudentCollection> stuCollList, ScopeType type)
        {
            RatingScopeCollection scopes = new RatingScopeCollection();

            foreach (StudentCollection eachStus in stuCollList.Values)
            {
                string name = string.Empty;

                foreach (Student eachStu in eachStus.Values)
                {
                    if (type == ScopeType.Class)
                    {
                        name = eachStu.ClassName;
                    }
                    else if (type == ScopeType.Dept)
                    {
                        name = eachStu.DeptName;
                    }
                    else if (type == ScopeType.GradeYear)
                    {
                        name = "年級:" + eachStu.GradeYear;
                    }
                    else
                    {
                        throw new ArgumentException("不支援此類型的排名範圍。(" + type.ToString() + ")");
                    }
                    break;
                }

                scopes.Add(new RatingScope(eachStus, type, name));
            }
            return(scopes);
        }
Exemplo n.º 2
0
            private RatingScopeCollection CreateScopes()
            {
                _allScope  = new RatingScopeCollection();
                _scopesSet = new Dictionary <ScopeType, RatingScopeCollection>();

                //將各類 Scope 存於集合中。
                _scopesSet.Add(ScopeType.Class, ScopeFactory.CreateScopes(_students, ScopeType.Class));
                _scopesSet.Add(ScopeType.Dept, ScopeFactory.CreateScopes(_students, ScopeType.Dept));
                _scopesSet.Add(ScopeType.GradeYear, ScopeFactory.CreateScopes(_students, ScopeType.GradeYear));

                //將所有 Scope 統一於一集合中。
                _allScope.AddRange(_scopesSet[ScopeType.Class]);
                _allScope.AddRange(_scopesSet[ScopeType.Dept]);
                _allScope.AddRange(_scopesSet[ScopeType.GradeYear]);

                return(_allScope);
            }
Exemplo n.º 3
0
        public static RatingScopeCollection CreateScopes(StudentCollection students, ScopeType scopeType)
        {
            Dictionary <string, StudentCollection> stuCollList = new Dictionary <string, StudentCollection>();

            foreach (Student eachStudent in students.Values)
            {
                string key = GetKey(eachStudent, scopeType);
                if (stuCollList.ContainsKey(key))
                {
                    stuCollList[key].AddStudent(eachStudent);
                }
                else
                {
                    StudentCollection stus = new StudentCollection();
                    stuCollList.Add(key, stus);
                    stus.AddStudent(eachStudent);
                }
            }

            RatingScopeCollection scopes = ConvertToScopes(stuCollList, scopeType);

            return(scopes);
        }