public override void Configure(ScheduleSettings settings, bool preConfigured) { if (!preConfigured) { _typedSettings = Upcaster.ToDerived<ScheduleSettings, DailyScheduleSettings>(settings); _timeOfDay = _typedSettings.TimeOfDay; base.Configure(_typedSettings, true); } else { _typedSettings = settings as DailyScheduleSettings; _timeOfDay = _typedSettings.TimeOfDay; base.Configure(settings, true); } }
public override void Configure(ScheduleSettings settings, bool preConfigured) { if (!preConfigured) { _typedSettings = Upcaster.ToDerived<ScheduleSettings, RecurringScheduleSettings>(settings); _dayOfMonth = _typedSettings.DayOfMonth; _dateRange = _typedSettings.DateRange; base.Configure(_typedSettings, true); } else { _typedSettings = settings as RecurringScheduleSettings; _dayOfMonth = _typedSettings.DayOfMonth; _dateRange = _typedSettings.DateRange; base.Configure(settings, true); } }
public virtual void Configure(ScheduleSettings settings, bool preconfigured) { //get rid of this make it work like all other classes, //then can get rid of chain of configuration. _settings = settings; _enabled = settings.Enabled; _settings = settings; _name = settings.Name; SubType = settings.SubType; Id = settings.Id; }
public override void Configure(ScheduleSettings settings, bool preConfigured) { if (!preConfigured) { _typedSettings = Upcaster.ToDerived<ScheduleSettings, TimerScheduleSettings>(settings); _frequency = _typedSettings.Frequency; _timeRange = _typedSettings.TimeRange; base.Configure(_typedSettings, true); } else { base.Configure(settings, true); } }
/// <summary> /// Creates an instance of the scheduling section defined in a provider /// specific configuration file or the application configuration file. /// The provider specific configuration file must live in the application /// directory and be named "RcScheduling.config" or "RcScheduling.dll.config". /// </summary> /// <remarks> /// Each time this method is called, a new instance of the scheduling section /// is created from the application configuration file. Because this is a /// rather expensive operation, a singleton of type <see cref="ScheduleSection"/> /// is provided in the static <see cref="ScheduleManager.Configuration"/> /// property. It is preferable for client code to use this singleton property /// instead of calling this method repeatedly. /// </remarks> /// /// <summary> /// Creates an instance of the scheduling section defined in the application /// configuration file. /// </summary> /// <remarks> /// Each time this method is called, a new instance of the scheduling section /// is created from the application configuration file. Because this is a /// rather expensive operation, a singleton of type <see cref="ScheduleSection"/> /// is provided in the static <see cref="ScheduleManager.Configuration"/> /// property. It is preferable for client code to use this singleton property /// instead of calling this method repeatedly. /// </remarks> /// <exception cref="ArgumentNullException"> /// Thrown if fileName is null. /// </exception> /// <exception cref="ArgumentException"> /// Thrown if fileName is empty. /// </exception> /// <exception cref="System.IO.FileNotFoundException"> /// Thrown if the file named fileName does not exist. /// </exception> /// <summary> /// Creates a schedule based on the specified settings. /// </summary> /// <exception cref="ArgumentNullException"> /// Thrown if scheduleSettings is null. /// </exception> /// public static ScheduleBase CreateSchedule(ScheduleSettings scheduleSettings) { if (scheduleSettings == null) { throw new ArgumentNullException("scheduleSettings"); } Type type = Type.GetType(scheduleSettings.Type, false, true); ScheduleBase schedule = (ScheduleBase)Activator.CreateInstance(type); if (schedule != null) { schedule.Configure(scheduleSettings, false); } else { throw new Exception("Unable to Create Schedule Settings"); } return schedule; }
/// <summary> /// Creates and returns an instance of a schedule. /// </summary> /// <remarks> /// The schedule name can be the name of a schedule defined in /// the application configuration file, a well-known schedule /// such as "Adler32", "Crc32", or "CrcX", a schedule that abides /// by the standard naming convention of /// "RcScheduling.{scheduleName}.{scheduleName}ScheduleBase" /// defined in an assembly named "RcScheduling.{scheduleName}" /// residing in the application directory or global assembly cache, /// or the type name of a schedule with the assembly of the schedule /// (e.g. "CustomSchedule.CustomSchedule, CustomSchedule"). /// </remarks> /// <param name="scheduleName"> /// The name of a schedule defined in the application configuration /// file, a well-known schedule such as "Adler32", "Crc32", or "CrcX", /// a schedule that abides by the standard naming convention of /// "RcScheduling.{scheduleName}.{scheduleName}ScheduleBase" /// defined in an assembly named "RcScheduling.{scheduleName}" /// residing in the application directory or global assembly cache, /// or the type name of a schedule with the assembly of the schedule /// (e.g. "CustomSchedule.CustomSchedule, CustomSchedule"). /// </param> /// <exception cref="ArgumentNullException"> /// Thrown if scheduleName is null. /// </exception> /// <exception cref="ArgumentException"> /// Thrown if scheduleName is empty. /// </exception> public static ScheduleBase CreateSchedule(string scheduleName) { if (scheduleName == null) { throw new ArgumentNullException("scheduleName"); } ScheduleSettings scheduleSettings = null; if (ScheduleManager.Configuration != null && ScheduleManager.Configuration.ScheduleSettings != null) { if (ScheduleManager.Configuration.Contains(scheduleName)) { scheduleSettings = ScheduleManager.Configuration.GetByName(scheduleName); } else { string scheduleType = ScheduleManager.Configuration.TypeOf(scheduleName); if (scheduleType == null) { // this was not a standard schedule, so if the name has any periods in it, // then we assume the name is actually a type name. Otherwise we assume the // name is in the standard format for schedules. if (scheduleName.IndexOfAny(new char[] { ',', '.' }) != -1) { scheduleType = scheduleName; } else { scheduleType = string.Format("Infrastructure.Scheduling.{0}Schedule, Infrastructure.Scheduling.{0}", scheduleName); //string.Format("Infrastructure.Scheduling.{0}.{0}Schedule, Infrastructure.Scheduling.{0}", scheduleName); } } scheduleSettings = new ScheduleSettings(); scheduleSettings.Name = scheduleName; scheduleSettings.Type = scheduleType; } } else { ScheduleSection section = new ScheduleSection(); string scheduleType= section.TypeOf(scheduleName); if (scheduleType != null) { scheduleSettings = new ScheduleSettings(); scheduleSettings.Name = scheduleName; scheduleSettings.Type = scheduleType; } } ScheduleBase schedule = null; if (scheduleSettings != null) { Type type = Type.GetType(scheduleSettings.Type, false, true); schedule = (ScheduleBase)Activator.CreateInstance(type); if (schedule != null) { schedule.Configure(scheduleSettings, false); } } if (schedule == null) { throw new Exception(string.Format("Unable to create {0}",scheduleName)); } return schedule; }
/// <summary> /// Creates a new instance of type <see cref="ScheduleEventArgs"/>. /// </summary> public ScheduleEventArgs(ScheduleBase schedule, ScheduleSettings settings) { _schedule = schedule; _settings = settings; }