Guest User

Untitled

a guest
Jan 22nd, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. public static void AddThemes(this IServiceCollection services, Action<ThemesOptions> setup) {
  2. services.Configure(setup);
  3. }
  4.  
  5. public class ThemesOptions {
  6. public IEnumerable<string> Themes { get; set; }
  7. }
  8.  
  9. services.AddThemes(options => {
  10. options.Themes = Configuration.GetSection("Themes").Get<ThemesOptions>().Themes;
  11. });
  12.  
  13. services.AddThemes(options => {
  14. options = Configuration.GetSection("Themes").Get<ThemesOptions>();
  15. });
  16.  
  17. services.AddThemes(options => Configuration.GetSection("Themes"));
  18.  
  19. public static void AddThemes(this IServiceCollection services, IConfiguration configuration) {
  20. services.Configure<ThemesOptions>(configuration.GetSection("Themes"));
  21. }
  22.  
  23. services.AddThemes(Configuration);
Add Comment
Please, Sign In to add comment