Skip to content

Commit

Permalink
housekeeping: Added Splat.Autofac README (#295)
Browse files Browse the repository at this point in the history
  • Loading branch information
RLittlesII authored and glennawatson committed Mar 12, 2019
1 parent a451b39 commit c4c789e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,13 @@ For each of the provided dependency resolver adapters, there is a specific packa

| Container | NuGet | Read Me
|---------|-------|-------|
| [Splat.Autofac][SplatAutofacNuGet] | [![SplatAutofacBadge]][SplatAutofacNuGet] |
| [Splat.Autofac][SplatAutofacNuGet] | [![SplatAutofacBadge]][SplatAutofacNuGet] | [Setup Autofac][SplatAutofacReadme]
| [Splat.DryIoc][SplatDryIocNuGet] | [![SplatDryIocBadge]][SplatDryIocNuGet] | [Setup DryIoc][SplatDryIocReadme]
| [Splat.SimpleInjector][SplatSimpleInjectorNuGet] | [![SplatSimpleInjectorBadge]][SplatSimpleInjectorNuGet] | |

[SplatAutofacNuGet]: https://www.nuget.org/packages/Splat.Autofac/
[SplatAutofacBadge]: https://img.shields.io/nuget/v/Splat.Autofac.svg
[SplatAutofacReadme]: ./src/Splat.Autofac/README.md
[SplatDryIocNuGet]: https://www.nuget.org/packages/Splat.DryIoc/
[SplatDryIocBadge]: https://img.shields.io/nuget/v/Splat.DryIoc.svg
[SplatDryIocReadme]: ./src/Splat.DryIoc/README.md
Expand Down
25 changes: 25 additions & 0 deletions src/Splat.Autofac/README.md
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.

0 comments on commit c4c789e

Please sign in to comment.