Ejemplo n.º 1
0
        public static void Main(string[] args)
        {
            var serviceProvider = new ServiceCollection()
                                  .AddLogging()
                                  .AddTransient <IGetWeatherForecastSvc, GetWeatherForecastSvc>()
                                  .BuildServiceProvider();


            ServiceLocator.SetLocatorProvider(serviceProvider);

            var request = new JList <WeatherForecastRequestDto>()
            {
                new WeatherForecastRequestDto()
                {
                    ID = 2003,
                },
                new WeatherForecastRequestDto()
                {
                    ID = 2004
                }
            };

            JList <WEATHER_FORECAST> result = new JList <WEATHER_FORECAST>();

            using (var svc =
                       new BulkServiceExecutorManager <IGetWeatherForecastSvc, WeatherForecastRequestDto>(request)) {
                svc.SetRequest((s, r) => s.Request = r)
                .AddFilter(s => s.Request.ID.isNotNull())
                .OnExecuted(s => {
                    result.Add(s.Result);
                    return(true);
                });
            }

            result.forEach(item => {
                Console.WriteLine(item.fromObjectToJson());
            });
        }