/// <summary> /// Adds the specified source. /// </summary> /// <param name="depot">The depot to consider.</param> /// <param name="datasource">The datasource to consider.</param> public static IBdoDatasourceDepot AddDatasource( this IBdoDatasourceDepot depot, Datasource datasource) { depot?.Add(datasource); return(depot); }
/// <summary> /// Adds sources from BindOpen configuration. /// </summary> /// <param name="depot">The depot to consider.</param> /// <param name="options">The host options to consider.</param> public static IBdoDatasourceDepot AddFromConfiguration(this IBdoDatasourceDepot depot, IBdoHostOptions options) { if (options?.AppSettings?.AppConfiguration?.Datasources != null) { foreach (var dataSource in options?.AppSettings?.AppConfiguration?.Datasources) { depot?.Add(dataSource); } } return(depot); }
/// <summary> /// Adds sources from host. /// </summary> /// <param name="depot">The datasource depot to consider.</param> /// <param name="config">The configuration to consider.</param> /// <param name="keyName">The key name to consider.</param> public static IBdoDatasourceDepot AddFromNetCoreConfiguration(this IBdoDatasourceDepot depot, IConfiguration config, string keyName = "connectionStrings") { if (depot != null && config != null) { var sections = config.GetSection(keyName).GetChildren(); foreach (var section in sections) { depot.Add( ItemFactory.CreateDatasource(section.Key, DatasourceKind.Database) .WithConfiguration( new BdoConnectorConfiguration().WithConnectionString(section.Value) as BdoConnectorConfiguration) ); } } ; return(depot); }