public override void Register() { RegisterLoader(); RegisterSelector(); App.Singleton <Translator>().Alias <ITranslator>().Alias("translation").Resolving((app, bind, obj) => { IConfigStore config = app.Make <IConfigStore>(); Translator tran = obj as Translator; IFileLoader loader = app.Make("translation.loader") as IFileLoader; ISelector selector = app.Make("translation.selector") as ISelector; tran.SetFileLoader(loader); tran.SetSelector(selector); if (config != null) { tran.SetLocale(config.Get(typeof(Translator), "default", "zh")); tran.SetRoot(config.Get(typeof(Translator), "root", null)); tran.SetFallback(config.Get(typeof(Translator), "fallback", null)); } return(obj); }); }
public AzureParallelInfrastructureCoordinatorFactory( Uri serviceName, IConfigStore configStore, string configSectionName, Guid partitionId, long replicaId, IInfrastructureAgentWrapper agent) { this.serviceName = serviceName.Validate("serviceName"); configStore.Validate("configStore"); configSectionName.Validate("configSectionName"); this.agent = agent.Validate("agent"); this.configSection = new ConfigSection(TraceType, configStore, configSectionName); this.partitionId = partitionId; this.replicaId = replicaId; try { this.tenantId = AzureHelper.GetTenantId(configSection); } catch (Exception ex) { // this happens on the Linux environment (since there is no registry) this.tenantId = PartitionIdPrefix + partitionId; TraceType.WriteWarning("Unable to get tenant Id from configuration. Using partition Id '{0}' text instead. Exception: {1}", this.tenantId, ex); } // TODO use tenant ID or config section name suffix as base trace ID? this.env = new CoordinatorEnvironment(this.serviceName.AbsoluteUri, this.configSection, tenantId, this.agent); this.activityLogger = new ActivityLoggerFactory().Create(env.CreateTraceType("Event")); this.policyAgentServiceWrapper = new PolicyAgentServiceWrapper(env, activityLogger); }
public static void PushValues(IConfigStore store) { ModuleProc PROC = new ModuleProc("ConfigStoreManager", "ModifyValue"); try { ConfigStoreManager manager = GetManager(store, true); if (manager != null) { IConfigStore storeSaved = manager.Store; if (Object.ReferenceEquals(store, storeSaved)) { manager.SetPropertyValues(); } else { manager.SetPropertyValues(store); } } } catch (Exception ex) { Log.Exception(PROC, ex); } }
public AdminController(IConfigStore configStore, EntityClient entityClient, ILogger <AdminController> logger, DiscoveryClient discoveryClient) { ConfigStore = configStore; EntityClient = entityClient; Logger = logger; DiscoveryClient = discoveryClient; }
private static ConfigStoreManager GetManager(IConfigStore store, bool ignoreInstance) { ModuleProc PROC = new ModuleProc("ConfigStoreManager", "GetManager"); try { Type typeofT = store.GetType(); if (_configStores.ContainsKey(typeofT)) { if (ignoreInstance) { return(_configStores[typeofT]); } IConfigStore storeSaved = _configStores[typeofT].Store; if (Object.ReferenceEquals(store, storeSaved)) { return(_configStores[typeofT]); } } } catch (Exception ex) { Log.Exception(PROC, ex); } return(null); }
public WindowsUpdateServiceCoordinator(IConfigStore configStore, string configSection, KeyValueStoreReplica kvsReplica, IStatefulServicePartition partition, IExceptionHandlingPolicy exceptionPolicy) { configStore.ThrowIfNull("configStore"); configSection.ThrowIfNullOrWhiteSpace("configSectionName"); kvsReplica.ThrowIfNull("kvsReplica"); partition.ThrowIfNull("partition"); exceptionPolicy.ThrowIfNull("exceptionPolicy"); this.commandProcessor = new FabricClientWrapper(); this.store = kvsReplica; this.partition = partition; this.packageRetriever = new UpdatePackageRetriever(); this.serviceName = new Uri(Constants.SystemServicePrefix + configSection); this.configStore = configStore; this.configSectionName = configSection; this.exceptionPolicy = exceptionPolicy; // Read all the configuration values string coordinatorType = configStore.ReadUnencryptedString(configSection, Constants.ConfigurationSection.CoordinatorType); this.testMode = false; this.testSrcDir = string.Empty; if (coordinatorType.Equals(Constants.ConfigurationSection.WUTestCoordinator)) { this.testSrcDir = configStore.ReadUnencryptedString(configSection, Constants.WUSCoordinator.TestCabFolderParam); this.testMode = true; } this.waitTimeBeforePolling = TimeSpan.FromMinutes(Constants.WUSCoordinator.PollingIntervalInMinutesDefault); this.windowsUpdateApiTimeout = TimeSpan.FromMinutes(Constants.WUSCoordinator.WuApiTimeoutInMinutesDefault); }
public TileHub(StatesClient statesClient, ServiceClient serviceClient, CalendarClient calendarClient, IConfigStore configStore) { StatesClient = statesClient; ServiceClient = serviceClient; ConfigStore = configStore; CalendarClient = calendarClient; }
protected async Task <IActionResult> SaveBaseTile(IConfigStore store, BaseTile tile) { await store.ManipulateConfig(c => { if (!string.IsNullOrWhiteSpace(Request.Form["originalName"])) { var existing = c.Tiles.FirstOrDefault(t => t.Name == Request.Form["originalName"]); if (existing == null) { TempData.AddError($"Unable to update tile with original name '{Request.Form["originalName"]}'."); } var i = c.Tiles.IndexOf(existing); c.Tiles.RemoveAt(i); c.Tiles.Insert(i, tile); } else { c.Tiles.Add(tile); } }); TempData.AddSuccess($"Successfully saved {tile.Type} tile '{tile.Name}'."); return(RedirectToAction("Index", "AdminTile")); }
internal CentralConfigFetcher(IApmLogger logger, IConfigStore configStore, ICentralConfigResponseParser centralConfigResponseParser, Service service, HttpMessageHandler httpMessageHandler = null, IAgentTimer agentTimer = null, string dbgName = null ) : this(logger, configStore, configStore.CurrentSnapshot, service, httpMessageHandler, agentTimer, dbgName) { _centralConfigResponseParser = centralConfigResponseParser; }
public override void Register() { App.Singleton <CsvStore>().Alias <ICsvStore>().Alias("csv.store").Resolving((app, bind, obj) => { CsvStore store = obj as CsvStore; IConfigStore confStore = app.Make <IConfigStore>(); string root = confStore.Get(typeof(CsvStore), "root", null); if (root != null) { IEnv env = app.Make <IEnv>(); IIOFactory io = app.Make <IIOFactory>(); IDisk disk = io.Disk(); #if UNITY_EDITOR if (env.DebugLevel == DebugLevels.Auto || env.DebugLevel == DebugLevels.Dev) { disk.SetConfig(new Hashtable() { { "root", env.AssetPath + env.ResourcesNoBuildPath } }); } #endif store.SetDirctory(disk.Directory(root)); } return(store); });; }
protected async Task <IActionResult> SaveBaseTile([FromRoute] string page, IConfigStore store, BaseTile tile) { await store.ManipulateConfig(c => { if (!string.IsNullOrWhiteSpace(Request.Form["originalName"])) { var existing = c[page].Tiles.FirstOrDefault(t => t.Name == Request.Form["originalName"]); if (existing == null) { TempData.AddError($"Unable to update tile with original name '{Request.Form["originalName"]}'."); } var i = c[page].Tiles.IndexOf(existing); if (i > -1) { c[page].Tiles.RemoveAt(i); c[page].Tiles.Insert(i, tile); } else { c[page].Tiles.Add(tile); } } else { c[page].Tiles.Add(tile); } }); TempData.AddSuccess($"Successfully saved {tile.Type} tile '{tile.Name}'.<br /><br /><i class=\"info circle icon\"></i><strong>Tip:</strong> If you just added a new tile, you should proceed to <strong><a href=\"/admin/pages/{page}/layout\">edit this page's layout</a></strong>."); return(RedirectToAction("Index", "AdminTile", new { page })); }
public RoleInstanceStatusMaxAllowedHealthPolicy(IConfigStore configStore, string configSectionName) : base(configStore, configSectionName) { maxAllowedKeyName = GetFullKeyName(HealthStateKeyName); AddConfigKey(maxAllowedKeyName, DefaultMaxAllowedHealthState.ToString()); }
public static IList <IBrokerAdapter> GetEnabledBrokerAdapters(IList <IBrokerAdapter> brokerAdapters, IConfigStore configStore) { var enabledBrokers = configStore.Config.Brokers.Where(b => b.Enabled).Select(b => b.Broker).ToList(); return(brokerAdapters.Where(b => enabledBrokers.Contains(b.Broker)).ToList()); }
private Program() { // One neat thing you could do is pass 'args[0]' from Main() // into the constructor here and use that as the path so that // you can specify where the config is loaded from when the bot starts up. _configStore = new JsonConfigStore <MyJsonConfig>("path_to_config.json", _commands); // If you have some Dictionary of data added to your config, // you should add a check to see if is initialized already or not. using (var config = _configStore.Load()) { if (config.SomeData == null) { config.SomeData = new Dictionary <ulong, string[]>(); // Remember to call Save() to save any changes config.Save(); } } _client = new DiscordSocketClient(new DiscordSocketConfig { // Standard 1.0 fare }); _services = ConfigureServices(_client, _commands, _configStore); }
public QuoteAggregator(IConfigStore configStore, IList <IBrokerAdapter> brokerAdapters, ITimer timer) { _config = configStore?.Config ?? throw new ArgumentNullException(nameof(configStore)); _brokerAdapters = brokerAdapters ?? throw new ArgumentNullException(nameof(brokerAdapters)); _timer = timer; Util.StartTimer(timer, _config.QuoteRefreshInterval, OnTimerTriggered); Aggregate(); }
public WrpStreamChannel( Uri baseUrl, string clusterId, IConfigStore configStore, string configSectionName) : base(baseUrl, clusterId, configStore, configSectionName) { }
internal WrpGatewayClient(Uri baseUrl, string clusterId, IConfigStore configStore, string configSectionName) { baseUrl.ThrowIfNull("baseUrl"); this.BaseUrl = baseUrl; this.clusterId = clusterId; this.ConfigStore = configStore; this.ConfigSectionName = configSectionName; }
public QuoteAggregator(IConfigStore configStore, IList <IBrokerAdapter> brokerAdapters, ITimer timer) { if (brokerAdapters == null) { throw new ArgumentNullException(nameof(brokerAdapters)); } _config = configStore?.Config ?? throw new ArgumentNullException(nameof(configStore)); _brokerAdapters = Util.GetEnabledBrokerAdapters(brokerAdapters, configStore); }
public PositionService(IConfigStore configStore, IBrokerAdapterRouter brokerAdapterRouter, ITimer timer) { _configStore = configStore ?? throw new ArgumentNullException(nameof(configStore)); _brokerAdapterRouter = brokerAdapterRouter ?? throw new ArgumentNullException(nameof(brokerAdapterRouter)); _timer = timer; Util.StartTimer(timer, _configStore.Config.PositionRefreshInterval, OnTimerTriggered); Refresh(); }
public VirtualStoreTest() { creds = new ConfigurationBuilder <ITestCredential>() .UseIniFile("c:\\tmp\\integration-tests.ini") .UseEnvironmentVariables() .Build(); store = CreateStore(); }
public void AddStore(IConfigStore store) { if (store == null) { throw new ArgumentNullException(nameof(store)); } _stores.Add(store); }
/// <summary> /// Initializes a new <see cref="RedisSyncService"/>. /// </summary> /// <param name="logService">Service used for logging.</param> /// <param name="configStore">Configuration storage instance.</param> /// <param name="multiplexerFactory">Facory that is able to create instances of <see cref="IConnectionMultiplexer"/>.</param> public RedisSyncService( ILog logService, IConfigStore configStore, IConnectionMultiplexerFactory multiplexerFactory) { this.logService = logService; this.configStore = configStore; this.multiplexerFactory = multiplexerFactory; }
/// <summary> /// Sets this object's <see cref="IConfigStore"/>. Can only be called once. /// </summary> /// <param name="store">the <see cref="IConfigStore"/> to add to this instance</param> /// <exception cref="InvalidOperationException">If this was called before.</exception> public void SetStore(IConfigStore store) { if (Store != null) { throw new InvalidOperationException($"{nameof(SetStore)} can only be called once"); } Store = store; ConfigRuntime.ConfigChanged(); }
IMergeStoreBuilder IStoreBuilder.CustomStore(IConfigStore store) { this.sourceInfos.Add(new StoreFactoryInfo() { StoreFactory = (srcInfo, cfg) => new ConfigStoreWithSource(srcInfo.Source, store), Source = new ConfigSource(Guid.NewGuid().ToString()), }); return(this); }
protected BaseRoleInstanceHealthPolicy(IConfigStore configStore, string configSectionName) { configStore.ThrowIfNull("configStore"); configSectionName.ThrowIfNullOrWhiteSpace("configSectionName"); this.configStore = configStore; this.configSectionName = configSectionName; Name = this.GetType().Name.Replace("HealthPolicy", string.Empty); }
/// <summary> Add SimplePermissions to your <see cref="CommandService"/> using a <see cref="DiscordSocketClient"/>. </summary> /// <param name="client">The <see cref="DiscordSocketClient"/> instance.</param> /// <param name="configStore">The <see cref="IConfigStore{TConfig}"/> instance.</param> /// <param name="map">The <see cref="IDependencyMap"/> instance.</param> /// <param name="logAction">Optional: A delegate or method that will log messages.</param> public static Task UseSimplePermissions( this CommandService cmdService, DiscordSocketClient client, IConfigStore <IPermissionConfig> configStore, IServiceCollection map, Func <LogMessage, Task> logAction = null) { map.AddSingleton(new PermissionsService(configStore, cmdService, client, logAction ?? (msg => Task.CompletedTask))); return(cmdService.AddModuleAsync <PermissionsModule>()); }
public ApplicationSettingsModel(IConfigStore store = null) { if (store == null) { return; } _store = store; RuntimeSettings = new ApplicationSettingsModel(); }
/// <summary> /// Initializes a new instance of the <see cref="Config"/> class. /// </summary> /// <param name="store"> /// The store that manages loading and saving the configuration data. /// </param> /// <param name="propertySearcher"> /// Provides a mechanism for searching the configuration properties of a Type. /// </param> /// <param name="converter"> /// Provides a mechanism that converts between configuration properties and string values that /// are stored in the IConfigStore. /// </param> protected Config(IConfigStore store, IConfigPropertySearcher propertySearcher, IStringConverter converter) { Contract.Requires <ArgumentNullException>(store != null); Contract.Requires <ArgumentNullException>(propertySearcher != null); Contract.Requires <ArgumentNullException>(converter != null); this.store = store; this.propertySearcher = propertySearcher; this.converter = converter; }
public BrokerAdapter(IRestClient restClient, IConfigStore configStore) { if (configStore == null) { throw new ArgumentNullException(nameof(configStore)); } _config = configStore.Config.Brokers.First(b => b.Broker == Broker); _restClient = restClient ?? throw new ArgumentNullException(nameof(restClient)); _restClient.BaseUrl = new Uri(ApiRoot); }
public void createNotificationForTask(int TaskId, string cfgSQLConnectionString) { this.cfgSQLConnectionString = cfgSQLConnectionString; configStore = StoreHandler.getConfigStore(cfgSQLConnectionString); baseURL = configStore.getString(BaseURL); templatepath = configStore.getString(Email_NotificationTemplate); taskStore = StoreHandler.getTaskStore(cfgSQLConnectionString); T_Task task = taskStore.getTaskById(TaskId); helper = new MailBodyHelper(); processStore = StoreHandler.getProcessStore(cfgSQLConnectionString); instance = processStore.getWorkflowInstance(task.WFId); mail = new SmtpUtils(configStore); if (task.Type.Equals("F") || task.Type.Equals("S")) { if (configStore.getBool(Email_Notifications_Tasks)) { string content = helper.getStateBody(task, baseURL, templatepath); List<string> recipients = new List<string>(); if (String.IsNullOrEmpty(instance.Owner)) { var subject = processStore.getProcessSubjectForWFId(task.WFId); userStore = StoreHandler.getUserStore(cfgSQLConnectionString); recipients.AddRange(userStore.getUsernamesForRole(subject.U_Role_Id)); } else { recipients.Add(instance.Owner); } foreach (string user in recipients) { mail.sendMail(user, "InFlow: " + task.Name + " #" + task.Id, content); } } } if (task.Type.Equals("R")) { if (configStore.getBool(Email_Notifications_Messages)) { messageStore = StoreHandler.getMessageStore(cfgSQLConnectionString); var messages = messageStore.getMessagesForReceiveStateTask(task.WFId, task.getTaskPropertiesAsListOfString()); foreach (var i in messages) { createReceiveNotification(i, task); } } } }
public void createNotificationForTask(int TaskId, string cfgSQLConnectionString) { this.cfgSQLConnectionString = cfgSQLConnectionString; configStore = StoreHandler.getConfigStore(cfgSQLConnectionString); baseURL = configStore.getString(BaseURL); templatepath = configStore.getString(Email_NotificationTemplate); taskStore = StoreHandler.getTaskStore(cfgSQLConnectionString); T_Task task = taskStore.getTaskById(TaskId); helper = new MailBodyHelper(); processStore = StoreHandler.getProcessStore(cfgSQLConnectionString); instance = processStore.getWorkflowInstance(task.WFId); mail = new SmtpUtils(configStore); if (task.Type.Equals("F") || task.Type.Equals("S")) { if (configStore.getBool(Email_Notifications_Tasks)) { string content = helper.getStateBody(task, baseURL, templatepath); List <string> recipients = new List <string>(); if (String.IsNullOrEmpty(instance.Owner)) { var subject = processStore.getProcessSubjectForWFId(task.WFId); userStore = StoreHandler.getUserStore(cfgSQLConnectionString); recipients.AddRange(userStore.getUsernamesForRole(subject.U_Role_Id)); } else { recipients.Add(instance.Owner); } foreach (string user in recipients) { mail.sendMail(user, "InFlow: " + task.Name + " #" + task.Id, content); } } } if (task.Type.Equals("R")) { if (configStore.getBool(Email_Notifications_Messages)) { messageStore = StoreHandler.getMessageStore(cfgSQLConnectionString); var messages = messageStore.getMessagesForReceiveStateTask(task.WFId, task.getTaskPropertiesAsListOfString()); foreach (var i in messages) { createReceiveNotification(i, task); } } } }
public void AddStore(IConfigStore store) { if (store == null) throw new ArgumentNullException(nameof(store)); _stores.Add(store); foreach(KeyValuePair<Type, ITypeParser> pc in GetBuiltInParsers()) { _parsers.TryAdd(pc.Key, pc.Value); } }
public SmtpUtils(IConfigStore cStore) { this.configStore = cStore; }
public MyContainer(IConfigStore store) : base("MyApp") { _store = store; }
public SettingsContainerTest() { _store = new InMemoryConfigStore(); }
public AllStoresTest() { _store = CreateStore(); }
public FixtureSettings(IConfigStore store) { _store = store; }
public void createNotificationForMessage(int MessageId, string cfgSQLConnectionString) { this.cfgSQLConnectionString = cfgSQLConnectionString; configStore = StoreHandler.getConfigStore(cfgSQLConnectionString); baseURL = configStore.getString(BaseURL); templatepath = configStore.getString(Email_NotificationTemplate); if (configStore.getBool(Email_Notifications_Messages)) { taskStore = StoreHandler.getTaskStore(cfgSQLConnectionString); T_Task task = taskStore.getReceiveTaskForMessageId(MessageId); if (task != null) { messageStore = StoreHandler.getMessageStore(cfgSQLConnectionString); mail = new SmtpUtils(configStore); processStore = StoreHandler.getProcessStore(cfgSQLConnectionString); instance = processStore.getWorkflowInstance(task.WFId); M_Message message = messageStore.getMessageBymsgId(MessageId); createReceiveNotification(message, task); } } }
/// <summary> /// Initializes a new instance of the <see cref="Config"/> class. /// </summary> /// <param name="store"> /// The store that manages loading and saving the configuration data. /// </param> /// <param name="propertySearcher"> /// Provides a mechanism for searching the configuration properties of a Type. /// </param> /// <param name="converter"> /// Provides a mechanism that converts between configuration properties and string values that /// are stored in the IConfigStore. /// </param> protected Config( IConfigStore store, IConfigPropertySearcher propertySearcher, IStringConverter converter ) { Contract.Requires<ArgumentNullException>( store != null ); Contract.Requires<ArgumentNullException>( propertySearcher != null ); Contract.Requires<ArgumentNullException>( converter != null ); this.store = store; this.propertySearcher = propertySearcher; this.converter = converter; }
/// <summary> /// Initializes a new instance of the <see cref="Config"/> class, /// which uses a <see cref="ConfigPropertySearcher"/> and a <see cref="TypeStringConverter"/>. /// </summary> /// <param name="store"> /// The store that manages loading and saving the configuration data. /// </param> protected Config( IConfigStore store ) : this(store, new ConfigPropertySearcher(), new TypeStringConverter()) { }