public string BuildConnectionString(IConnectionstringArguments connectionstringArguments) { var connectionstringBuilderStrategy = _connectionstringBuilderFactory.Make(connectionstringArguments.DatabaseType); var connectionstringFactory = new ConnectionstringFactory(connectionstringBuilderStrategy); var connectionString = connectionstringFactory.BuildConnection(connectionstringArguments); return connectionString; }
private static string BuildConnectionString(IConnectionstringArguments arguments) { string connectionString; if (string.IsNullOrEmpty(arguments.Username) && string.IsNullOrEmpty(arguments.Password)) { connectionString = string.Format("Provider={0};Data Source={1};", arguments.Provider, arguments.DataSource); } else { connectionString = string.Format("Provider={0};Data Source={1};User ID={2};Password={3};", arguments.Provider, arguments.DataSource, arguments.Username, arguments.Password); } return connectionString; }
public bool Validate(IConnectionstringArguments connectionstringArguments) { bool isValid; var arguments = (SqlServerConnectionstringArguments)connectionstringArguments; var message = string.Empty; if (string.IsNullOrEmpty(arguments.DataSource)) { message = "DataSource can't be null or Empty"; } else if (string.IsNullOrEmpty(arguments.DatabaseName)) { message = "DatabaseName can't be null or Empty"; } else if (string.IsNullOrEmpty(arguments.Provider)) { message = "Provider can't be null or Empty"; } else if (string.IsNullOrEmpty(arguments.Password) && !string.IsNullOrEmpty(arguments.Username)) { message = "Password can't be null or Empty"; } else if (string.IsNullOrEmpty(arguments.Username) && !string.IsNullOrEmpty(arguments.Password)) { message = "Username can't be null or Empty"; } if (string.IsNullOrEmpty(message)) { isValid = true; } else { throw new ConnectionstringArgumentsException(message); } return isValid; }
public string BuildConnectionstring(IConnectionstringArguments connectionstringArguments) { var connectionString = string.Empty; if(connectionstringArguments.IsA<SqlServerConnectionstringArguments>()) { var arguments = (SqlServerConnectionstringArguments)connectionstringArguments; var areValid = _connectionstringArgumentsValidator.Validate(arguments); if (areValid) { connectionString = BuildConnectionString(arguments); } } else { var message = string.Format("SqlServerConnectionstringBuilderStrategy.BuildConnectionstring accept only type of SqlServerConnectionstringArguments, not type of {0}.", connectionstringArguments.GetType()); throw new ArgumentException(message); } return connectionString; }
public string BuildConnection(IConnectionstringArguments connectionstringArguments) { return _connectionstringBuilderStrategy.BuildConnectionstring(connectionstringArguments); }
public IQueryable<string> GetViewsName(IConnectionstringArguments connectionstringArguments) { var connectionstring = _connectionstringBuilder.BuildConnectionString(connectionstringArguments); return _schemaReader.GetViewsName(connectionstring).AsQueryable(); }
public IQueryable<Table> GetTables(IConnectionstringArguments connectionstringArguments) { var connectionstring = _connectionstringBuilder.BuildConnectionString(connectionstringArguments); return _schemaReader.GetTables(connectionstring).AsQueryable(); }
public Table GetTable(IConnectionstringArguments connectionstringArguments, string tableName) { var connectionstring = _connectionstringBuilder.BuildConnectionString(connectionstringArguments); return _schemaReader.GetTable(connectionstring, tableName); }
public string BuildConnectionstring(IConnectionstringArguments connectionstringArguments) { throw new NotImplementedException(); }