AgileConfigSource.cs 990 B

1234567891011121314151617181920212223242526272829303132333435
  1. using Microsoft.Extensions.Configuration;
  2. using Microsoft.Extensions.Logging;
  3. namespace Agile.Config.Client
  4. {
  5. public static class AgileConfitBuilderExt
  6. {
  7. public static IConfigurationBuilder AddAgileConfig(
  8. this IConfigurationBuilder builder,
  9. IConfigClient client)
  10. {
  11. return builder.Add(new AgileConfigSource(client));
  12. }
  13. public static IConfigurationBuilder AddAgileConfig(
  14. this IConfigurationBuilder builder)
  15. {
  16. return builder.Add(new AgileConfigSource(new ConfigClient()));
  17. }
  18. }
  19. public class AgileConfigSource : IConfigurationSource
  20. {
  21. protected IConfigClient ConfigClient { get; }
  22. public AgileConfigSource(IConfigClient client)
  23. {
  24. ConfigClient = client;
  25. }
  26. public IConfigurationProvider Build(IConfigurationBuilder builder)
  27. {
  28. return new AgileConfigProvider(ConfigClient);
  29. }
  30. }
  31. }