AgileConfigProvider.cs 790 B

123456789101112131415161718192021222324252627282930
  1. using Microsoft.Extensions.Configuration;
  2. using Microsoft.Extensions.Logging;
  3. using System;
  4. namespace Agile.Config.Client
  5. {
  6. public class AgileConfigProvider : ConfigurationProvider
  7. {
  8. private ConfigClient Client { get; }
  9. public AgileConfigProvider(IConfigClient client)
  10. {
  11. Client = client as ConfigClient;
  12. }
  13. /// <summary>
  14. /// load方法调用ConfigClient的Connect方法,Connect方法会在连接成功后拉取所有的配置。
  15. /// </summary>
  16. public override void Load()
  17. {
  18. Client.ConfigChanged += (arg) =>
  19. {
  20. this.OnReload();
  21. };
  22. Client.ConnectAsync().GetAwaiter().GetResult() ;
  23. Data = Client.Data;
  24. }
  25. }
  26. }