private static IObjectService Setup() { IStartupSetting setting = ConfigSectionHandler.GetConfig("htb.devfx").ToSetting <StartupSetting>("startup"); string configServiceTypeName = null; string objectServiceTypeName = null; if (setting != null && setting.CoreSetting != null) { if (setting.CoreSetting.ConfigServiceSetting != null) { configServiceTypeName = setting.CoreSetting.ConfigServiceSetting.TypeName; } if (setting.CoreSetting.ObjectServiceSetting != null) { objectServiceTypeName = setting.CoreSetting.ObjectServiceSetting.TypeName; } } IConfigService configServiceInstance = null; if (!string.IsNullOrEmpty(configServiceTypeName)) { configServiceInstance = (IConfigService)TypeHelper.CreateObject(configServiceTypeName, typeof(IConfigService), false); } if (configServiceInstance == null) { configServiceInstance = Config.ConfigService.Default; } if (configServiceInstance is IConfigServiceInternal) { ((IConfigServiceInternal)configServiceInstance).Init(setting); } else if (configServiceInstance is IInitializable) { ((IInitializable)configServiceInstance).Init(); } IObjectService objectServiceInstance = null; if (!string.IsNullOrEmpty(objectServiceTypeName)) { objectServiceInstance = (IObjectService)TypeHelper.CreateObject(objectServiceTypeName, typeof(IObjectService), false); } if (objectServiceInstance == null) { objectServiceInstance = new DefaultObjectService(); } if (objectServiceInstance is IObjectServiceInternal) { ((IObjectServiceInternal)objectServiceInstance).Init(configServiceInstance); } else if (objectServiceInstance is IInitializable) { ((IInitializable)objectServiceInstance).Init(); } return(objectServiceInstance); }
public void StartMonitoring(Func <IEnumerable <ConcurrentDictionary <string, SettingNode> > > getTargetFunc, CancellationToken cancellationToken, TimeSpan pollingInterval) { ConfigSectionHandler section = (ConfigSectionHandler)ConfigurationManager.GetSection("Config"); int num = section != null ? section.InvalidationTimeoutSeconds : 300; Task.Factory.StartNew(new Action <object>(TimeoutInvalidator.DoChecks), (object)new TimeoutInvalidator.Context() { GetSettingsFunc = getTargetFunc, Token = cancellationToken, SettingAbsoluteExpiration = TimeSpan.FromSeconds((double)num), PollingInterval = pollingInterval }, cancellationToken, TaskCreationOptions.LongRunning, TaskScheduler.Default); }