首页 > 其他分享 >Service模块读取AppSettings.json

Service模块读取AppSettings.json

时间:2022-09-24 11:45:20浏览次数:55  
标签:set Service get AppSettings settings json public httpClient

创建对应的映射类:

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";
    }

  

标签:set,Service,get,AppSettings,settings,json,public,httpClient
From: https://www.cnblogs.com/friend/p/16725255.html

相关文章