/// <summary> /// Retrieves all ConnectionParams from configuration parameters from /// "connections" section.If "connection" section is present instead, than it /// returns a list with only one ConnectionParams. /// </summary> /// <param name="config">a configuration parameters to retrieve connections</param> /// <param name="configAsDefault">boolean parameter for default configuration. If "true" /// the default value will be added to the result.</param> /// <returns>a list of retrieved ConnectionParams</returns> public static List <ConnectionParams> ManyFromConfig(ConfigParams config, bool configAsDefault = true) { var result = new List <ConnectionParams>(); // Try to get multiple connections first var connections = config.GetSection("connections"); if (connections.Count > 0) { var connectionSections = connections.GetSectionNames(); foreach (var section in connectionSections) { var connection = connections.GetSection(section); result.Add(new ConnectionParams(connection)); } } // Then try to get a single connection else { var connection = config.GetSection("connection"); if (connection.Count > 0) { result.Add(new ConnectionParams(connection)); } // Apply default if possible else if (configAsDefault) { result.Add(new ConnectionParams(config)); } } return(result); }
public static List <CredentialParams> ManyFromConfig(ConfigParams config, bool configAsDefault = true) { var result = new List <CredentialParams>(); // Try to get multiple credentials first var credentials = config.GetSection("credentials"); if (credentials.Count > 0) { var sectionsNames = credentials.GetSectionNames(); foreach (var section in sectionsNames) { var credential = credentials.GetSection(section); result.Add(new CredentialParams(credential)); } } // Then try to get a single connection else { var credential = config.GetSection("credential"); if (credential.Count > 0) { result.Add(new CredentialParams(credential)); } // Apply defaults else if (configAsDefault) { result.Add(new CredentialParams(config)); } } return(result); }
/// <summary> /// Configures component by passing configuration parameters. /// </summary> /// <param name="config">configuration parameters to be set.</param> public virtual void Configure(ConfigParams config) { _config = config.SetDefaults(_defaultConfig); _options = _options.Override(_config.GetSection("options")); _databaseServer = _config.GetAsNullableString("connection.host"); _databasePort = _config.GetAsIntegerWithDefault("connection.port", 1433); _sshConfigs = _sshConfigs.Override(_config.GetSection("ssh")); _sshEnabled = _sshConfigs.GetAsBooleanWithDefault("enabled", false); _connectionResolver.Configure(_config); }
public static ContainerInfo FromConfig(ConfigParams config) { var result = new ContainerInfo(); var info = config.GetSection("info"); result.Name = info.GetAsNullableString("name"); result.Description = info.GetAsNullableString("description"); result.Properties = config.GetSection("properties"); return(result); }
/// <summary> /// Reads connections from configuration parameters. /// Each section represents an individual Connectionparams /// </summary> /// <param name="connections">configuration parameters to be read</param> private void ReadConnections(ConfigParams connections) { lock (_lock) { _items.Clear(); var connects = connections.GetSection("connections"); if (connections.Count > 0) { var connectionSections = connects.GetSectionNames(); foreach (var key in connectionSections) { var config = connects.GetSection(key); var item = new DiscoveryItem() { Key = key, Connection = new ConnectionParams(config) }; _items.Add(item); } } } }
/// <summary> /// Configures the component with specified parameters. /// </summary> /// <param name="config">configuration parameters to set.</param> /// See <see cref="ConfigParams"/> public void Configure(ConfigParams config) { ConfigParams dependencies = config.GetSection("dependencies"); foreach (string name in dependencies.Keys) { string locator = dependencies.Get(name); if (locator == null) { continue; } try { Descriptor descriptor = Descriptor.FromString(locator); if (descriptor != null) { _dependencies[name] = descriptor; } else { _dependencies[name] = locator; } } catch (Exception) { _dependencies[name] = locator; } } }
/// <summary> /// Configures component by passing configuration parameters. /// </summary> /// <param name="config">configuration parameters to be set.</param> public virtual void Configure(ConfigParams config) { config = config.SetDefaults(_defaultConfig); _connectionResolver.Configure(config); _options = _options.Override(config.GetSection("options")); }
protected virtual void RegisterOpenApiSpecFromMetadata() { var swaggerConfig = _config.GetSection("swagger"); var doc = new RestOpenApiDocument(_baseRoute, swaggerConfig, _routesWithMetadata); RegisterOpenApiSpec(doc.ToString()); }
/// <summary> /// Configures component by passing configuration parameters. /// </summary> /// <param name="config">Configuration parameters to be set.</param> public virtual void Configure(ConfigParams config) { var parameters = config.GetSection("parameters"); if (parameters.Count > 0) { _parameters = parameters; } }
/// <summary> /// Configures component by passing configuration parameters. /// </summary> /// <param name="config">configuration parameters to be set.</param> public virtual void Configure(ConfigParams config) { config = config.SetDefaults(_defaultConfig); _connectionResolver.Configure(config); _options = _options.Override(config.GetSection("options")); _connectTimeout = config.GetAsIntegerWithDefault("options.connect_timeout", _connectTimeout); //_timeout = config.GetAsIntegerWithDefault("options.timeout", _timeout); }
/// <summary> /// Configures component by passing configuration parameters. /// </summary> /// <param name="config">configuration parameters to be set.</param> public void Configure(ConfigParams config) { Name = config.GetAsStringWithDefault("name", Name); Name = config.GetAsStringWithDefault("info.name", Name); Description = config.GetAsStringWithDefault("description", Description); Description = config.GetAsStringWithDefault("info.description", Description); Properties = config.GetSection("properties"); }
public EmailHttpClientV1(object config) : base("v1/email") { ConfigParams thisConfig = ConfigParams.FromValue(config); this._defaultParameters = thisConfig.GetSection("parameters"); if (config != null) { this.Configure(thisConfig); } }
public static ConfigParams Resolve(ConfigParams config, bool configAsDefault = true) { var options = config.GetSection("options"); if (options.Count == 0) { options = config; } return(options); }
/// <summary> /// Configures component by passing configuration parameters. /// </summary> /// <param name="config">configuration parameters to be set.</param> public virtual void Configure(ConfigParams config) { config = config.SetDefaults(_defaultConfig); _connectionResolver.Configure(config); _options = _options.Override(config.GetSection("options")); _areSessionsSupported = _options.GetAsBooleanWithDefault("sessions_supported", true); }
/// <summary> /// Configures component by passing configuration parameters. /// </summary> /// <param name="config">configuration parameters to be set.</param> public virtual void Configure(ConfigParams config) { config = config.SetDefaults(_defaultConfig); _connectionResolver.Configure(config); _collectionName = config.GetAsStringWithDefault("collection", _collectionName); _options = _options.Override(config.GetSection("options")); }
/// <summary> /// Configures component by passing configuration parameters. /// </summary> /// <param name="config">configuration parameters to be set.</param> public virtual void Configure(ConfigParams config) { config = config.SetDefaults(_defaultConfig); _connectionResolver.Configure(config); _options = _options.Override(config.GetSection("options")); _retries = config.GetAsIntegerWithDefault("options.retries", _retries); _baseRoute = config.GetAsStringWithDefault("base_route", _baseRoute); }
public EmailDirectClientV1(object config) : base() { this._dependencyResolver.Put("controller", new Descriptor("pip-services-email", "controller", "*", "*", "*")); ConfigParams thisConfig = ConfigParams.FromValue(config); this._defaultParameters = thisConfig.GetSection("parameters"); if (config != null) { this.Configure(thisConfig); } }
/// <summary> /// Reads credentials from configuration parameters. /// Each section represents an individual CredentialParams /// </summary> /// <param name="config">configuration parameters to be read</param> public void ReadCredentials(ConfigParams config) { lock (_lock) { _items.Clear(); var sections = config.GetSectionNames(); foreach (var section in sections) { var value = config.GetSection(section); var creadentials = CredentialParams.FromConfig(value); _items.Add(section, creadentials); } } }
/// <summary> /// Configure are configures component by passing configuration parameters. /// </summary> /// <param name="config">Configuration parameters to be set</param> public void Configure(ConfigParams config) { config = config.SetDefaults(_defaultConfig); _connectionResolver.Configure(config); _logger.Configure(config); _options = _options.Override(config.GetSection("options")); _clientId = config.GetAsStringWithDefault("client_id", _clientId); _retryConnect = config.GetAsBooleanWithDefault("options.retry_connect", _retryConnect); _connectTimeout = config.GetAsIntegerWithDefault("options.connect_timeout", _connectTimeout); _reconnectTimeout = config.GetAsIntegerWithDefault("options.reconnect_timeout", _reconnectTimeout); _keepAliveTimeout = config.GetAsIntegerWithDefault("options.keepalive_timeout", _keepAliveTimeout); }
public static ContainerConfig FromConfig(ConfigParams config) { var result = new ContainerConfig(); if (config == null) { return(result); } foreach (var section in config.GetSectionNames()) { var componentConfig = config.GetSection(section); result.Add(ComponentConfig.FromConfig(componentConfig)); } return(result); }
/// <summary> /// Configures component by passing configuration parameters. /// </summary> /// <param name="config">configuration parameters to be set.</param> public void Configure(ConfigParams config) { _connectionResolver.Configure(config); _credentialResolver.Configure(config); _options = config.GetSection("options"); }