コード例 #1
0
        public DealersAndVehiclesServiceTests()
        {
            ServiceProvider serviceProvider = new ServiceCollection()
                                              .AddHttpClient()
                                              .AddSingleton <IApiService, ApiService>()
                                              .AddSingleton <IDataRetrievalService, DataRetrievalService>()
                                              .AddSingleton <IDealersAndVehiclesService, DealersAndVehiclesService>()
                                              .BuildServiceProvider();

            _dealersAndVehiclesService = serviceProvider.GetService <IDealersAndVehiclesService>();
        }
コード例 #2
0
        private static void ConfigureServices()
        {
            Log.Logger = new LoggerConfiguration().WriteTo.File("consoleapp.log").CreateLogger();
            //Configuring services
            ServiceProvider serviceProvider = new ServiceCollection()
                                              .AddLogging(configure => configure.AddSerilog())
                                              .AddHttpClient()
                                              .AddSingleton <IApiService, ApiService>()
                                              .AddSingleton <IDealersAndVehiclesService, DealersAndVehiclesService>()
                                              .AddSingleton <IDataRetrievalService, DataRetrievalService>()
                                              .BuildServiceProvider();

            dealersAndVehiclesService = serviceProvider.GetService <IDealersAndVehiclesService>();
        }