ProjectsCollection.cs
上传用户:autodoor
上传日期:2022-08-04
资源大小:9973k
文件大小:2k
- using System;
- using System.Collections;
- namespace qminoa.BLL.PM
- {
- public class ProjectsCollection : ArrayList
- {
- public enum ProjectFields
- {
- InitValue,
- Name,
- ManagerUserName,
- CompletionDate,
- Duration
- }
- public void Sort(ProjectFields sortField, bool isAscending)
- {
- switch (sortField)
- {
- case ProjectFields.Name:
- base.Sort(new NameComparer());
- break;
- case ProjectFields.ManagerUserName:
- base.Sort(new ManagerUserNameComparer());
- break;
- case ProjectFields.CompletionDate:
- base.Sort(new CompletionDateComparer());
- break;
- case ProjectFields.Duration:
- base.Sort(new DurationComparer());
- break;
- }
- if (!isAscending) base.Reverse();
- }
- private sealed class NameComparer : IComparer
- {
- public int Compare(object x, object y)
- {
- Project first = (Project) x;
- Project second = (Project) y;
- return first.Name.CompareTo(second.Name);
- }
- }
- private sealed class ManagerUserNameComparer : IComparer
- {
- public int Compare(object x, object y)
- {
- Project first = (Project) x;
- Project second = (Project) y;
- return first.ManagerUserName.CompareTo(second.ManagerUserName);
- }
- }
- private sealed class CompletionDateComparer : IComparer
- {
- public int Compare(object x, object y)
- {
- Project first = (Project) x;
- Project second = (Project) y;
- return first.EstCompletionDate.CompareTo(second.EstCompletionDate);
- }
- }
- private sealed class DurationComparer : IComparer
- {
- public int Compare(object x, object y)
- {
- Project first = (Project) x;
- Project second = (Project) y;
- return first.EstDuration.CompareTo(second.EstDuration);
- }
- }
- }
- }