Advertisement
Guest User

Untitled

a guest
Feb 20th, 2020
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. public class FieldMapRepoModule : Module
  2. {
  3. protected override void Load(ContainerBuilder builder)
  4. {
  5. var thisAssembly = typeof(FieldMapRepoModule).Assembly;
  6.  
  7. builder.Register(c =>
  8. {
  9. var configuration = c.Resolve<IConfigurationRoot>();
  10. return configuration.GetSection("FieldMapRepoSettings").Get<Environment>();
  11. }).As<IEnvironment>();
  12.  
  13. builder.Register(c =>
  14. {
  15. var configuration = c.Resolve<IConfigurationRoot>();
  16. var contextBuilder = new DbContextOptionsBuilder<GenesisDbContext>();
  17. var sqlConfiguration = configuration.GetSection("FieldMapRepoSettings").GetValue<string>("ConnectionString");
  18. contextBuilder.UseSqlServer(sqlConfiguration);
  19.  
  20. var dbContextOptions = contextBuilder.Options;
  21. return dbContextOptions;
  22. }).SingleInstance();
  23.  
  24. builder.RegisterType<GenesisDbContext>().InstancePerLifetimeScope();
  25.  
  26. builder.RegisterAssemblyTypes(thisAssembly)
  27. .AsClosedTypesOf(typeof(Core.FieldValues.IRepository<>))
  28. .InstancePerLifetimeScope();
  29. }
  30. }
  31.  
  32.  
  33. JSON:
  34. {
  35. "GenesisHttpConfiguration": {
  36. "UserName": "xxxx",
  37. "Password": "xxxxx",
  38. "Host": "xxxxxxx",
  39. "AuthCookieUri": "xxxxxx",
  40. "AuthCookieName": "xxxxxx"
  41. },
  42. "APPINSIGHTS_INSTRUMENTATIONKEY": "xxxxxx",
  43. "StorageConfiguration": {
  44. "FiberJobs": "xxxxxx"
  45. },
  46. "FieldMapRepoSettings": {
  47. "ConnectionString": "xxxxxxx",
  48. "Environment": {
  49. "EnvironmentName": "DEV"
  50. }
  51. }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement