-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
39 lines (29 loc) · 1020 Bytes
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using System;
using System.Diagnostics;
using External.Library;
using Microsoft.Extensions.DependencyInjection;
using Serilog;
using Serilog.Injection;
namespace Konsol
{
class Program
{
static void Main(string[] args)
{
var services = new ServiceCollection();
services.AddExternalLibraryServices();
services.AddSerilogServices();
services.AddTransient<Runner>();
var provider = services.BuildServiceProvider();
var log = provider.GetService<ILogger>();
log.Information("ILogger service reference obtained.");
var runner = provider.GetService<Runner>();
runner.DoAction("Hello there");
var divider = provider.GetService<IDivideByZero>();
divider.CrashThyself(999);
log.Information("Ready to exit.");
Console.WriteLine("Press any key...");
Console.ReadKey();
}
}
}