Skip to content

Commit e0c48a5

Browse files
committed
2 parents c1ef821 + a0b3f3f commit e0c48a5

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

README.md

+19-2
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,22 @@ Install-Package Unity.Microsoft.DependencyInjection
1818
```C#
1919
public static IWebHost BuildWebHost(string[] args) =>
2020
WebHost.CreateDefaultBuilder(args)
21-
.UseUnityServiceProvider()
21+
.UseUnityServiceProvider() <---- Add this line
2222
.UseStartup<Startup>()
2323
.Build();
2424
```
25-
- Add method to your `Startup` class
25+
26+
- In case Unity container configured via application configuration or by convention this container could be used to initalize service provider.
27+
28+
```C#
29+
public static IWebHost BuildWebHost(string[] args) =>
30+
WebHost.CreateDefaultBuilder(args)
31+
.UseUnityServiceProvider(_container) <---- or add this line
32+
.UseStartup<Startup>()
33+
.Build();
34+
```
35+
36+
- Add optional method to your `Startup` class
2637
```C#
2738
public void ConfigureContainer(IUnityContainer container)
2839
{
@@ -31,5 +42,11 @@ public void ConfigureContainer(IUnityContainer container)
3142
}
3243
```
3344

45+
### Startup
46+
47+
At the moment it is not possible to resolve Startup class from Unity even if it is configured as default container. [An Issue](https://github.com/aspnet/Hosting/issues/1309) has been filed with ASPNET team to fix it. Once it is resolved it would be possible to resolve Startap class itself from the Unity container.
48+
49+
## Examples
50+
3451
For example of using Unity with Core 2.0 Web application follow [this link](https://github.com/unitycontainer/examples/tree/master/src/AspNetCoreExample)
3552

0 commit comments

Comments
 (0)