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