Skip to content

Commit b9a0b02

Browse files
committed
improve documentation
1 parent 19e740a commit b9a0b02

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

ReadMe.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,19 @@ var app = ConsoleApp.Create(args, options =>
398398
});
399399
```
400400

401+
`ConsoleAppBuilder` itself is `IHostBuilder` so you can use any configuration methods like `ConfigureServices`, `ConfigureLogging`, etc. If method chain is not returns `ConsoleAppBuilder`(for example, using external lib's extension methods), can not get `ConsoleApp` directly. In that case, use `BuildAsConsoleApp()` instead of `Build()`.
402+
403+
`ConsoleApp` exposes some utility properties.
404+
405+
* `IHost` Host
406+
* `ILogger<ConsoleApp>` Logger
407+
* `IServiceProvider` Services
408+
* `IConfiguration` Configuration
409+
* `IHostEnvironment` Environment
410+
* `IHostApplicationLifetime` Lifetime
411+
412+
`Run()` and `RunAsync(CancellationToken)` to finally invoke application. Run is shorthand of `RunAsync().GetAwaiter().GetResult()` so receives same result of `await RunAsync()`. On Entrypoint, there is not much need to do `await RunAsync()`. Therefore, it is usually a good to choose `Run()`.
413+
401414
Delegate convention
402415
---
403416
`AddCommand` accepts `Delegate` in argument. In C# 10.0 allows naturaly syntax of lambda expressions.
@@ -550,10 +563,6 @@ This is most easy to create many commands so useful for application batch that r
550563

551564
Commands are searched from loaded assemblies(in default `AppDomain.CurrentDomain.GetAssemblies()`), when does not touch other assemblies type, it will be trimmed and can not load it. In that case, use `AddAllCommandType(params Assembly[] searchAssemblies)` overload to pass target assembly, for example `AddAllCommandType(typeof(Foo).Assembly)` preserve types.
552565

553-
Run vs RunAsync
554-
---
555-
`ConsoleApp` has `Run` and `RunAsync` methods to finally invoke application. `Run` is shorthand of `RunAsync().GetAwaiter().GetResult()` so receives same result of `await RunAsync()`. On Entrypoint, there is not much need to do `await RunAsync()`. Therefore, it is usually a good to choose `Run`.
556-
557566
Complex Argument
558567
---
559568
If the argument is not primitive, you can pass JSON string.

0 commit comments

Comments
 (0)