private bool HasConnectionStringParameterExtract(string parameterName, out string newVal) { newVal = null; if (!string.IsNullOrEmpty(parameterName)) { string divider = DatabaseNexus.GetConnectionStringParameterDivider(DatabaseType); if (divider != null && divider.Length == 1) { string match = DatabaseNexus.GetConnectionStringPart(DatabaseType, parameterName, "[^" + divider + "]*"); if (match != null) { string str = ConnectionString; if (!string.IsNullOrEmpty(str)) { string newStr = Regex.Replace(str, match, ""); if (str.Length != newStr.Length) { newVal = newStr; return(true); } } } } } return(false); }
/// <summary> /// Sets the connection string parameter. /// </summary> /// <param name="parameterName">Name of the parameter.</param> /// <param name="parameterValue">The parameter value.</param> public virtual void SetConnectionStringParameter(string parameterName, string parameterValue) { if (!string.IsNullOrEmpty(parameterName)) { RemoveConnectionStringParameter(parameterName); ConnectionString += DatabaseNexus.GetConnectionStringPart(DatabaseType, parameterName, parameterValue); } }
/// <summary> /// Initializes a new instance of the <see cref="Database"/> class. /// </summary> /// <param name="databaseType">Type of the database.</param> /// <param name="connectionString">The connection string.</param> public Database(DatabaseType databaseType, string connectionString) { if (Log.Enabled) { Log.Entry("Database", databaseType, connectionString); } InitializeCurrent(); DatabaseType = databaseType; DbProviderFactory = DatabaseNexus.GetDbProviderFactory(databaseType); if (!string.IsNullOrEmpty(connectionString)) { ConnectionProvider = new DatabaseConnectionProvider(connectionString); ConnectionProvider.DbProviderFactory = DbProviderFactory; } if (Log.Enabled) { Log.Exit("Database", DbProviderFactory, ConnectionProvider); } }
/// <summary> /// Sets the connection string parameter. /// </summary> /// <param name="parameterName">Name of the parameter.</param> /// <param name="parameterValue">The parameter value.</param> public virtual void SetConnectionStringParameter(ConnectionParameterName parameterName, string parameterValue) { SetConnectionStringParameter(DatabaseNexus.GetConnectionStringParameter(DatabaseType, parameterName), parameterValue); }
/// <summary> /// Determines whether [has connection string parameter] [the specified parameter name]. /// </summary> /// <param name="parameterName">Name of the parameter.</param> /// <returns> /// <c>true</c> if [has connection string parameter] [the specified parameter name]; otherwise, <c>false</c>. /// </returns> public virtual bool HasConnectionStringParameter(ConnectionParameterName parameterName) { return(HasConnectionStringParameter(DatabaseNexus.GetConnectionStringParameter(DatabaseType, parameterName))); }
/// <summary> /// Gets the database. /// </summary> /// <param name="type">The type.</param> /// <param name="server">The server.</param> /// <param name="databaseName">Name of the database.</param> /// <param name="userName">Name of the user.</param> /// <param name="password">The password.</param> /// <param name="port">The port.</param> /// <param name="otherParameters">The other parameters.</param> /// <returns></returns> public static IDatabase GetDatabase(DatabaseType type, string server, string databaseName, string userName, string password, int port, params string[] otherParameters) { return(GetDatabase(type, DatabaseNexus.GetConnectionString(type, server, databaseName, userName, password, port, otherParameters))); }