Guest User

Untitled

a guest
Jun 20th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. public IConfigurationRoot Configuration { get; }
  2.  
  3. public Startup(IHostingEnvironment env)
  4. {
  5. var builder = new ConfigurationBuilder()
  6. .SetBasePath(env.ContentRootPath)
  7. .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
  8. .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
  9. .AddEnvironmentVariables();
  10.  
  11. if (env.IsDevelopment())
  12. {
  13. // This will push telemetry data through Application Insights pipeline faster, allowing you to view results immediately.
  14. builder.AddApplicationInsightsSettings(developerMode: true);
  15. }
  16.  
  17. Configuration = builder.Build();
  18.  
  19. Environment = env;
  20. }
  21.  
  22. services.AddSingleton<IConfiguration>(Configuration);
  23.  
  24. private readonly IConfiguration _configuration;
  25. private readonly string _connectionString;
  26.  
  27. public SuaClasseRepository(IConfiguration configuration)
  28. {
  29. _configuration = configuration;
  30. _connectionString = configuration.GetConnectionString("DefaultConnection");
  31. }
  32.  
  33. "ConnectionStrings": {
  34. "DefaultConnection": "myDatabaseConnectionString"
  35. }
Add Comment
Please, Sign In to add comment