File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change 11
11
12
12
var app = ConsoleApp . Create ( args ) ;
13
13
14
+ var a = app . Services ;
15
+ var b = app . Configuration ;
16
+ var c = app . Environment ;
17
+ var d = app . Lifetime ;
18
+ var e = app . Logger ;
19
+
14
20
app . AddSubCommands < FooBarBaz > ( ) ;
15
21
16
22
//app.AddAllCommandType();
Original file line number Diff line number Diff line change 1
- using Microsoft . Extensions . DependencyInjection ;
1
+ using Microsoft . Extensions . Configuration ;
2
+ using Microsoft . Extensions . DependencyInjection ;
2
3
using Microsoft . Extensions . Hosting ;
3
4
using Microsoft . Extensions . Logging ;
4
5
using System ;
@@ -18,6 +19,10 @@ public class ConsoleApp
18
19
19
20
public IHost Host { get ; }
20
21
public ILogger < ConsoleApp > Logger { get ; }
22
+ public IServiceProvider Services => Host . Services ;
23
+ public IConfiguration Configuration => Host . Services . GetRequiredService < IConfiguration > ( ) ;
24
+ public IHostEnvironment Environment => Host . Services . GetRequiredService < IHostEnvironment > ( ) ;
25
+ public IHostApplicationLifetime Lifetime => Host . Services . GetRequiredService < IHostApplicationLifetime > ( ) ;
21
26
22
27
internal ConsoleApp ( IHost host )
23
28
{
You can’t perform that action at this time.
0 commit comments