public IScheduler CreateScheduler(ISchedulerConfig config, ISchedulerType type) { if (config == null || !config.Enabled) { return(null); } lock (mSchedulers.SyncRoot) { CScheduler scheduler = mSchedulers[config.Name] as CScheduler; if (scheduler == null) { if (type == null) { type = mSystemContext.SchedulerTypeManager.GetConfig(config.Type); } if (type != null && type.Enabled && !type.SchedulerClass.Equals("")) { if (!type.FileName.Equals("")) { scheduler = CommonUtil.CreateInstance(SystemContext, type.FileName, type.SchedulerClass) as CScheduler; } else { scheduler = CommonUtil.CreateInstance(type.SchedulerClass) as CScheduler; } } if (scheduler != null) { if (scheduler.Init(this, config, type)) { scheduler.OnSchedulerStateChanged += new SchedulerStateChanged(DoSchedulerStateChanged); scheduler.OnSchedulerEvent += new SchedulerEvent(DoSchedulerEvent); mSchedulers.Add(scheduler.Name, scheduler); scheduler.RefreshState(); } else { return(null); } } } else { scheduler.Config = config; } return(scheduler); } }
public IScheduler CreateInstance(ISchedulerConfig config, ISchedulerType type, object owner) { if (config == null || !config.Enabled) { return(null); } if (type == null) { type = mSystemContext.SchedulerTypeManager.GetConfig(config.Type); } CScheduler scheduler = null; if (type != null && type.Enabled && !type.SchedulerClass.Equals("")) { if (!type.FileName.Equals("")) { scheduler = CommonUtil.CreateInstance(SystemContext, type.FileName, type.SchedulerClass) as CScheduler; } else { scheduler = CommonUtil.CreateInstance(type.SchedulerClass) as CScheduler; } } if (scheduler != null) { scheduler.Owner = owner; if (scheduler.Init(this, config, type)) { return(scheduler); } } return(null); }