internal AppServerDataConnection(AppServerImpl server) { this._SERVER = server; string dbProvider; this._INNER_CONNECTION = this._SERVER .TryGetServerDbConnectionDataByConfig(out dbProvider); if (this._INNER_CONNECTION == null) { throw new NotSupportedException(string.Format("'{0}' provider is NOT supported!", dbProvider)); } }
/// <summary> /// Tries to return the <see cref="IAdoDataConnection" /> based on the current startup configuration. /// </summary> /// <param name="dbProvider">The variable where to write the name of the database provider from startup config to.</param> /// <returns>The connection data or <see langword="null" /> if not found.</returns> public IAdoDataConnection TryGetServerDbConnectionDataByConfig(out string dbProvider) { IAdoDataConnection result = null; var provider = this.TryGetServerDbProviderByConfig(out dbProvider); if (provider != null) { var genericAdoType = typeof(global::MarcelJoachimKloubert.CLRToolbox.Data.AdoDataConnection <>); var adoType = genericAdoType.MakeGenericType(provider); var connStr = this.StartupConfig .GetValue <string>(category: CONFIG_CATEGORY_DATABASE, name: CONFIG_VALUE_CONNECTION_STRING); result = (global::MarcelJoachimKloubert.CLRToolbox.Data.IAdoDataConnection)Activator.CreateInstance(adoType, args: new object[] { connStr }); } return(result); }