2020-03-25 20:32:28 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Threading.Tasks;
|
2020-03-24 08:47:08 +00:00
|
|
|
|
using FarmmapsApi;
|
|
|
|
|
using FarmmapsApi.Models;
|
2020-03-25 20:32:28 +00:00
|
|
|
|
using FarmmapsApi.Services;
|
2020-03-24 08:47:08 +00:00
|
|
|
|
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
|
2020-03-25 20:32:28 +00:00
|
|
|
|
.AddConsole()
|
2020-03-24 08:47:08 +00:00
|
|
|
|
.AddFilter("System.Net.Http", LogLevel.Warning))
|
|
|
|
|
.AddFarmmapsServices(configuration)
|
2020-03-25 16:49:00 +00:00
|
|
|
|
.AddTransient<NitrogenService>()
|
2020-03-24 22:26:02 +00:00
|
|
|
|
.AddSingleton<IApp, NbsApp>()
|
2020-03-24 08:47:08 +00:00
|
|
|
|
.BuildServiceProvider();
|
2020-03-25 20:32:28 +00:00
|
|
|
|
|
|
|
|
|
await serviceProvider.GetService<FarmmapsApiService>().AuthenticateAsync();
|
|
|
|
|
await serviceProvider.GetService<FarmmapsEventHub>().StartEventHub();
|
2020-03-24 08:47:08 +00:00
|
|
|
|
await serviceProvider.GetService<IApp>().RunAsync();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|