Ignore:
Timestamp:
4/28/2009 12:13:51 PM (6 years ago)
Author:
lowjoel
Message:

Ran static code analysis on Manager.

-Do not initialise class members to default values (runtime will handle that)
-Deserialisation constructors should be marked protected for unsealed classes
-Classes implementing ICollection should end with Collection (Mainly fixed here is ErasureTargetsCollection?)
-ISerializable.GetObjectData? should be marked virtual
-Use proper camel casing (Prng, Guid, FileName? etc)
-Enumeration values should be Camel casing
-Bitfields should be marked with the [Flags] attribute
-Implement the proper IDisposable pattern - one Dispose() and one Dispose(bool) - the latter doing the clean ups for both Dispose and finalisers
-public variables should instead be properties
-Abstract classes should have protected constructors
-Renamed Schedule.Type to Schedule.ScheduleType? to prevent ambiguity with GetType?()
-There shouldn't be a need to pass reference variables by reference

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eraser6/Manager/Schedule.cs

    r826 r905  
    128128                switch (type) 
    129129                { 
    130                     case ScheduleUnit.DAILY: 
     130                    case ScheduleUnit.Daily: 
    131131                        if (frequency != 1) 
    132132                            result = S._("Once every {0} days", frequency); 
     
    134134                            result = S._("Once every day"); 
    135135                        break; 
    136                     case ScheduleUnit.WEEKDAYS: 
     136                    case ScheduleUnit.Weekdays: 
    137137                        result = S._("Every weekday"); 
    138138                        break; 
    139                     case ScheduleUnit.WEEKLY: 
    140                         if ((weeklySchedule & DaysOfWeek.MONDAY) != 0) 
     139                    case ScheduleUnit.Weekly: 
     140                        if ((weeklySchedule & DaysOfWeek.Monday) != 0) 
    141141                            result = S._("Every Monday, {0}"); 
    142                         if ((weeklySchedule & DaysOfWeek.TUESDAY) != 0) 
     142                        if ((weeklySchedule & DaysOfWeek.Tuesday) != 0) 
    143143                            result += S._("Every Tuesday, {0}"); 
    144                         if ((weeklySchedule & DaysOfWeek.WEDNESDAY) != 0) 
     144                        if ((weeklySchedule & DaysOfWeek.Wednesday) != 0) 
    145145                            result += S._("Every Wednesday, {0}"); 
    146                         if ((weeklySchedule & DaysOfWeek.THURSDAY) != 0) 
     146                        if ((weeklySchedule & DaysOfWeek.Thursday) != 0) 
    147147                            result += S._("Every Thursday, {0}"); 
    148                         if ((weeklySchedule & DaysOfWeek.FRIDAY) != 0) 
     148                        if ((weeklySchedule & DaysOfWeek.Friday) != 0) 
    149149                            result += S._("Every Friday, {0}"); 
    150                         if ((weeklySchedule & DaysOfWeek.SATURDAY) != 0) 
     150                        if ((weeklySchedule & DaysOfWeek.Saturday) != 0) 
    151151                            result += S._("Every Saturday, {0}"); 
    152                         if ((weeklySchedule & DaysOfWeek.SUNDAY) != 0) 
     152                        if ((weeklySchedule & DaysOfWeek.Sunday) != 0) 
    153153                            result += S._("Every Sunday, {0}"); 
    154154 
     
    157157                            S._("once every {0} weeks.", frequency)); 
    158158                        break; 
    159                     case ScheduleUnit.MONTHLY: 
     159                    case ScheduleUnit.Monthly: 
    160160                        if (frequency == 1) 
    161161                            result = S._("On day {0} of every month", monthlySchedule); 
     
    212212            /// Daily schedule type 
    213213            /// </summary> 
    214             DAILY, 
     214            Daily, 
    215215 
    216216            /// <summary> 
    217217            /// Weekdays-only schedule type 
    218218            /// </summary> 
    219             WEEKDAYS, 
     219            Weekdays, 
    220220 
    221221            /// <summary> 
    222222            /// Weekly schedule type 
    223223            /// </summary> 
    224             WEEKLY, 
     224            Weekly, 
    225225 
    226226            /// <summary> 
    227227            /// Monthly schedule type 
    228228            /// </summary> 
    229             MONTHLY 
     229            Monthly 
    230230        } 
    231231 
     
    233233        /// The days of the week, with values usable in a bitfield. 
    234234        /// </summary> 
     235        [Flags] 
    235236        public enum DaysOfWeek 
    236237        { 
    237             SUNDAY = 1 << DayOfWeek.Sunday, 
    238             MONDAY = 1 << DayOfWeek.Monday, 
    239             TUESDAY = 1 << DayOfWeek.Tuesday, 
    240             WEDNESDAY = 1 << DayOfWeek.Wednesday, 
    241             THURSDAY = 1 << DayOfWeek.Thursday, 
    242             FRIDAY = 1 << DayOfWeek.Friday, 
    243             SATURDAY = 1 << DayOfWeek.Saturday 
     238            None = 0, 
     239            Sunday = 1 << DayOfWeek.Sunday, 
     240            Monday = 1 << DayOfWeek.Monday, 
     241            Tuesday = 1 << DayOfWeek.Tuesday, 
     242            Wednesday = 1 << DayOfWeek.Wednesday, 
     243            Thursday = 1 << DayOfWeek.Thursday, 
     244            Friday = 1 << DayOfWeek.Friday, 
     245            Saturday = 1 << DayOfWeek.Saturday 
    244246        } 
    245247 
     
    247249        /// The type of schedule. 
    248250        /// </summary> 
    249         public ScheduleUnit Type 
     251        public ScheduleUnit ScheduleType 
    250252        { 
    251253            get { return type; } 
     
    261263            get 
    262264            { 
    263                 if (Type != ScheduleUnit.DAILY && Type != ScheduleUnit.WEEKLY && 
    264                     Type != ScheduleUnit.MONTHLY) 
     265                if (ScheduleType != ScheduleUnit.Daily && ScheduleType != ScheduleUnit.Weekly && 
     266                    ScheduleType != ScheduleUnit.Monthly) 
    265267                    throw new ArgumentException(S._("The ScheduleUnit of the schedule does " + 
    266268                        "not require a frequency value, this field would contain garbage.")); 
     
    296298            get 
    297299            { 
    298                 if (Type != ScheduleUnit.WEEKLY) 
     300                if (ScheduleType != ScheduleUnit.Weekly) 
    299301                    throw new ArgumentException(S._("The ScheduleUnit of the schedule does " + 
    300302                        "not require the WeeklySchedule value, this field would contain garbage")); 
     
    320322            get 
    321323            { 
    322                 if (Type != ScheduleUnit.MONTHLY) 
     324                if (ScheduleType != ScheduleUnit.Monthly) 
    323325                    throw new ArgumentException(S._("The ScheduleUnit of the schedule does " + 
    324326                        "not require the MonthlySchedule value, this field would contain garbage")); 
     
    356358                nextRun = nextRun.AddSeconds(executionTime.Second - nextRun.Second); 
    357359 
    358                 switch (Type) 
     360                switch (ScheduleType) 
    359361                { 
    360                     case ScheduleUnit.DAILY: 
     362                    case ScheduleUnit.Daily: 
    361363                    { 
    362364                        //First assume that it is today that we are running the schedule 
     
    370372                        break; 
    371373                    } 
    372                     case ScheduleUnit.WEEKDAYS: 
     374                    case ScheduleUnit.Weekdays: 
    373375                    { 
    374376                        while (nextRun < DateTime.Now || 
     
    378380                        break; 
    379381                    } 
    380                     case ScheduleUnit.WEEKLY: 
     382                    case ScheduleUnit.Weekly: 
    381383                    { 
    382384                        if (weeklySchedule == 0) 
     
    405407                        break; 
    406408                    } 
    407                     case ScheduleUnit.MONTHLY: 
     409                    case ScheduleUnit.Monthly: 
    408410                        //Step the number of months since the last run 
    409411                        if (LastRun != DateTime.MinValue) 
     
    444446        private bool CanRunOnDay(DateTime date) 
    445447        { 
    446             if (Type != ScheduleUnit.WEEKLY) 
     448            if (ScheduleType != ScheduleUnit.Weekly) 
    447449                throw new ArgumentException(S._("The ScheduleUnit of the schedule does " + 
    448450                    "not use the WeeklyScheduly value, this field would contain garbage")); 
Note: See TracChangeset for help on using the changeset viewer.