public static IServiceCollection AddRewardMoneyGrantService(this IServiceCollection collection) { var appfilters = new AppTypes[] { AppTypes.Official }; var apps = "https://www.yourc.club/api/sharing/QueryMerchantDetails" .GetUriJsonContent <JObject>().TryGetValues <MerchantDetails>("$.data") .SelectMany((merchant) => { return(merchant.Apps.Where(app => appfilters.Any(x => x == app.AppType)) .Select(x => new { App = x, MerchantId = merchant.Id, MerchantName = merchant.BrandName })); }); foreach (var app in apps) { var state = new RewardMoneyGrantState(new RewardMoneyGrantSetting() { WxApp = app.App, BrandName = app.MerchantName }); collection.Add(new ServiceDescriptor(typeof(IASfPWorkItem), new WorkItemWithDataflow <RewardMoneyGrantState, RewardLogging>(state))); } return(collection); }