-
-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
housekeeping: Added Splat.Autofac README (#295)
- Loading branch information
1 parent
a451b39
commit c4c789e
Showing
2 changed files
with
27 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Splat.Autofac | ||
|
||
## Using Autofac | ||
|
||
Splay.Autofac is an adapter for `IMutableDependencyResolver`. It allows you to register your application dependencies in a Autofac `Container`. You can then use the container as Splat's internal dependency resolver. | ||
|
||
### Register the Container | ||
|
||
```cs | ||
var container = new ContainerBuilder(); | ||
container.RegisterType<MainPage>().As<IViewFor<MainViewModel>>(); | ||
container.RegisterType<SecondaryPage>().As<IViewFor<SecondaryViewModel>>(); | ||
container.RegisterType<MainViewModel>().AsSelf(); | ||
container.RegisterType<SecondaryViewModel>().AsSelf(); | ||
``` | ||
|
||
### Register the Adapter to Splat | ||
|
||
```cs | ||
container.UseAutofacDependencyResolver(); | ||
``` | ||
|
||
### Use the Locator | ||
|
||
Now calls to `Locator.Current` will resolve to the underlying Autofac container. In the case of ReactiveUI, platform registrations will now happen in the Autofac container. So when the platform calls to resolve dependencies, the will resolve from the Autofac container. |