Skip to content

Commit 552fcf8

Browse files
authored
Update README.md
1 parent a3b231f commit 552fcf8

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

README.md

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,25 @@ Install-Package Unity.Microsoft.DependencyInjection
1616
- In the `WebHostBuilder` add `UseUnityServiceProvider(...)` method
1717

1818
```C#
19-
public static IWebHost BuildWebHost(string[] args) =>
20-
WebHost.CreateDefaultBuilder(args)
21-
.UseUnityServiceProvider() <---- Add this line
22-
.UseStartup<Startup>()
23-
.Build();
19+
public static IHostBuilder CreateHostBuilder(string[] args) =>
20+
Host.CreateDefaultBuilder(args)
21+
.UseUnityServiceProvider() <---- Add this line
22+
.ConfigureWebHostDefaults(webBuilder =>
23+
{
24+
webBuilder.UseStartup<Startup>();
25+
});
2426
```
2527

2628
- In case Unity container configured via application configuration or by convention this container could be used to initialize service provider.
2729

2830
```C#
29-
public static IWebHost BuildWebHost(string[] args) =>
30-
WebHost.CreateDefaultBuilder(args)
31-
.UseUnityServiceProvider(_container) <---- or add this line
32-
.UseStartup<Startup>()
33-
.Build();
31+
public static IHostBuilder CreateHostBuilder(string[] args) =>
32+
Host.CreateDefaultBuilder(args)
33+
.UseUnityServiceProvider(_container) <---- Add this line
34+
.ConfigureWebHostDefaults(webBuilder =>
35+
{
36+
webBuilder.UseStartup<Startup>();
37+
});
3438
```
3539

3640
- Add optional method to your `Startup` class

0 commit comments

Comments
 (0)