forked from FarmMaps/FarmMapsApiClient
36 lines
1.2 KiB
C#
36 lines
1.2 KiB
C#
using System;
|
|
using System.Threading.Tasks;
|
|
using FarmmapsApi;
|
|
using FarmmapsApi.Models;
|
|
using FarmmapsApi.Services;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
namespace FarmmapsApiSamples
|
|
{
|
|
class Program
|
|
{
|
|
private static async Task Main(string[] args)
|
|
{
|
|
IConfiguration config = new ConfigurationBuilder()
|
|
.AddJsonFile("appsettings.json", false, true)
|
|
.Build();
|
|
|
|
var configuration = config.Get<Configuration>();
|
|
|
|
var serviceProvider = new ServiceCollection()
|
|
.AddLogging(opts => opts
|
|
.AddConsole()
|
|
.AddFilter("System.Net.Http", LogLevel.Warning))
|
|
.AddFarmmapsServices(configuration)
|
|
.AddTransient<NitrogenService>()
|
|
.AddSingleton<IApp, Application>()
|
|
.BuildServiceProvider();
|
|
|
|
await serviceProvider.GetService<FarmmapsApiService>().AuthenticateAsync();
|
|
await serviceProvider.GetService<FarmmapsEventHub>().StartEventHub();
|
|
await serviceProvider.GetService<IApp>().RunAsync();
|
|
}
|
|
}
|
|
} |