public void DbClient_Instance_Should_Match_For_Lambda_Options(IModularDbClient dbClient, string connString) { IServiceCollection services = new ServiceCollection(); services.AddSingleton <IModularDbClient>(_dbClient); services.AddLocalizedContentTextRepository(options => { options.ConnectionString = connString; options.DbClient = dbClient; }); var scopeFactory = services.BuildServiceProvider().GetRequiredService <IServiceScopeFactory>(); using var scope = scopeFactory.CreateScope(); var provider = scope.ServiceProvider; var repo = provider.GetRequiredService <TInterface>(); var actualDbClient = DataUtility.GetReflectedMemberValueByName(repo, "_dbClient"); Assert.AreEqual(dbClient ?? _dbClient, actualDbClient); var actualConnString = DataUtility.GetReflectedMemberValueByName(repo, "_connString"); Assert.AreEqual(connString ?? "", actualConnString); }
/// <summary> /// Initializes a new instance of the <see cref="LocalizedContentFieldRepository"/> class. /// </summary> /// <param name="dbClient">The database client.</param> /// <param name="connString">The connection string.</param> /// TODO Edit XML Comment Template for #ctor public LocalizedContentFieldRepository(IModularDbClient dbClient, string connString) : base(dbClient, connString) { _sGetRecord = SpGetRecord; _sDeleteRecord = SpDeleteRecord; _sSaveRecord = SpSaveRecord; _sGetAllRecords = SpListRecord; }
public static void ImportSqlObject(string name, Server server, IModularDbClient dbClient) { string filename = ""; if (dbClient.GetRecordScalar <int>(null, server.ConnectionContext.ConnectionString, new RepositoryMethodDefinition($"SELECT OBJECT_ID('{name}')", CommandType.Text, null, null, null)) < 1) { if (name.StartsWith("dbo.sp_", StringComparison.InvariantCultureIgnoreCase)) { filename = $"../SqlSchema/StoredProcedure/{name}.SQL"; } else if (name.StartsWith("dbo.vw", StringComparison.InvariantCultureIgnoreCase)) { filename = $"../SqlSchema/View/{name}.SQL"; } else { filename = $"../SqlSchema/Table/{name}.SQL"; } string initScript = File.ReadAllText(filename); Console.WriteLine($"Executing SQL script '{filename}'"); server.ConnectionContext.ExecuteNonQuery(initScript); } }
public TileData(IDataRecord o, string connString = null, IModularDbClient dbClient = null) : base("") { InitDatabase(connString, dbClient); if (o == null) { return; } Source = DataUtility.ParseString(o, "SourceUrl"); StatusCode = string.IsNullOrWhiteSpace(Source) ? HttpStatusCode.NotFound : HttpStatusCode.OK; Status = ""; _x = DataUtility.ParseInt(o, "CoordX"); _y = DataUtility.ParseInt(o, "CoordY"); _zoom = DataUtility.ParseInt(o, "Zoom"); SetImageData((byte[])o["ImageData"]); }
public void Instance_Should_Be_Added_To_ServiceCollection(IModularDbClient dbClient, string connString) { IServiceCollection services = new ServiceCollection(); services.AddSingleton <IModularDbClient>(_dbClient); services.AddLocalizedContentTextRepository(options => { options.ConnectionString = connString; options.DbClient = dbClient; }); var scopeFactory = services.BuildServiceProvider().GetRequiredService <IServiceScopeFactory>(); using var scope = scopeFactory.CreateScope(); var provider = scope.ServiceProvider; var repo = provider.GetRequiredService <TInterface>(); Assert.IsNotNull(repo); Assert.IsInstanceOfType(repo, typeof(TInterface)); }
public void DbClient_Instance_Should_Match_For_Null_Arguments_With_Options_Dependency_Injection(IModularDbClient dbClient, string connString) { IServiceCollection services = new ServiceCollection(); services.AddSingleton(new LocalizedContentTextRepositoryOptions() { DbClient = _dbClient, ConnectionString = connString }); services.AddLocalizedContentTextRepository(); var scopeFactory = services.BuildServiceProvider().GetRequiredService <IServiceScopeFactory>(); using var scope = scopeFactory.CreateScope(); var provider = scope.ServiceProvider; var repo = provider.GetRequiredService <TInterface>(); var actualClient = DataUtility.GetReflectedMemberValueByName(repo, "_dbClient"); // Test seems to fail for equivalency when testing for same object, so will fall back to checking for signatures for now) Assert.AreEqual((dbClient ?? _dbClient).ToString(), actualClient.ToString()); var actualConnString = DataUtility.GetReflectedMemberValueByName(repo, "_connString"); Assert.AreEqual(connString ?? "", actualConnString); }
protected void InitDatabase(string connString = null, IModularDbClient dbClient = null) { _dbClient = dbClient ?? new ModularDbClient <NullDbConnection, NullDbCommand, NullDbParameter>(); _connString = connString; }
public TileData(int x, int y, int zoom, string engine = "Osm", string connString = null, IModularDbClient dbClient = null) : base("") { InitDatabase(connString, dbClient); Source = GetTileUrl(x, y, zoom, engine); FetchTileDataByUrl(x, y, zoom, Source); }
public TileData(string source, HttpStatusCode statusCode = HttpStatusCode.Ambiguous, string status = "", byte[] imageData = null, string connString = null, IModularDbClient dbClient = null) : base(source, statusCode, status, imageData) { InitDatabase(connString, dbClient); }
/// <summary> /// Initializes a new instance of the <see cref="WizardFactoryRepository"/> class. /// </summary> /// <param name="dbClient">The database client.</param> /// <param name="connString">The connection string.</param> /// TODO Edit XML Comment Template for #ctor public WizardFactoryRepository(IModularDbClient dbClient, string connString) : base(dbClient, connString) { _sGetRecord = SpGetRecord; }
public MapEngine(string tileEngine = null, string connString = null, IModularDbClient dbClient = null) { _tileTemplate = TileSources.Sources.FirstOrDefault(kvp => kvp.Key.Equals(tileEngine ?? "", StringComparison.InvariantCultureIgnoreCase)).Value; _connString = connString; _dbClient = dbClient ?? new ModularDbClient <NullDbConnection, NullDbCommand, NullDbParameter>(); }
public ModularDbClientUserStore(string connString, IModularDbClient dbClient) { _dbClient = dbClient; _builder = _dbClient.GetConnectionBuilder(connString); InitializeDefinitions(); }