学海无涯

导航

Service模块读取AppSettings.json

创建对应的映射类:

public class AppSettings
{
    //public Connectionstrings ConnectionStrings { get; set; }
    public string PurchaseUrl { get; set; }
    public string SignalrHubUrl { get; set; }
    public bool ActivateCampaignDetailFunction { get; set; }
    public Logging Logging { get; set; }
    public bool UseCustomizationData { get; set; }
}

  

public class OrderingService : IOrderingService
{
    private HttpClient _httpClient;
    private readonly string _remoteServiceBaseUrl;
    private readonly IOptions<AppSettings> _settings;


    public OrderingService(HttpClient httpClient, IOptions<AppSettings> settings)
    {
        _httpClient = httpClient;
        _settings = settings;

        _remoteServiceBaseUrl = $"{settings.Value.PurchaseUrl}/o/api/v1/orders";
    }

  

posted on 2022-09-24 11:33  宁静致远.  阅读(22)  评论(0编辑  收藏  举报