Skip to content

Commit ea1d100

Browse files
authored
Merge pull request #183 from Cysharp/keyedservices
Add support FromKeyedServices
2 parents c03f683 + 3cf59f1 commit ea1d100

File tree

8 files changed

+413
-212
lines changed

8 files changed

+413
-212
lines changed

ReadMe.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -937,7 +937,7 @@ app.Add("", ([FromServices] MyService service, int x, int y) => Console.WriteLin
937937
app.Run(args);
938938
```
939939

940-
When passing to a lambda expression or method, the `[FromServices]` attribute is used to distinguish it from command parameters. When passing a class, Constructor Injection can be used, resulting in a simpler appearance.
940+
When passing to a lambda expression or method, the `[FromServices]` attribute is used to distinguish it from command parameters. When passing a class, Constructor Injection can be used, resulting in a simpler appearance. Lambda, method, constructor, filter, etc, all DI supported parameter also supports `[FromKeyedServices]`.
941941

942942
Let's try injecting a logger and enabling output to a file. The libraries used are Microsoft.Extensions.Logging and [Cysharp/ZLogger](https://github.com/Cysharp/ZLogger/) (a high-performance logger built on top of MS.E.Logging). If you are referencing `Microsoft.Extensions.Logging`, you can call `ConfigureLogging` from `ConsoleAppBuilder`.
943943

sandbox/CliFrameworkBenchmark/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// This benchmark project is based on CliFx.Benchmarks.
1+
// This benchmark project is based on CliFx.Benchmarks.
22
// https://github.com/Tyrrrz/CliFx/tree/master/CliFx.Benchmarks/
33

44
using BenchmarkDotNet.Configs;

0 commit comments

Comments
 (0)