public ClassX() { _rsProfile = xxx; // Get the RSProfile object _dbConnectionCreator = new RSDatabaseConnectionCreator(_rsProfile); RSDatabaseNames databaseName = yyy; // get the RSDatabaseNames var useWindowsAuthentication = true; var testConnection = false; _sqlConnection = _dbConnectionCreator.CreateConnection(databaseName, useWindowsAuthentication, testConnection); }
public void QueryExecution(string SQLQuery) { var profile = new RsProfile(); var rsConnectionCreator = new RSDatabaseConnectionCreator(profile); using (var sqlConnection = rsConnectionCreator.CreateConnection(...Parameters here...)){ SqlCommand command = new SqlCommand(SQLQuery, sqlConnection); } var file = new StreamWriter(@"D:\Project\rsDeployer\ImportedQuery.txt"); file.WriteLine(command); file.Close(); }
// Constructor injection public Consumer(RSDatabaseConnectionCreator connectionCreator) { _connectionCreator = connectionCreator; }