Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added custom-dependency-inversion.md (#161) #161

Merged
merged 1 commit into from
Aug 24, 2018
Merged

Added custom-dependency-inversion.md (#161) #161

merged 1 commit into from
Aug 24, 2018

Conversation

RLittlesII
Copy link
Member

Resolves #134

@RLittlesII RLittlesII changed the title Added custom-dependency-inversion.md Added custom-dependency-inversion.md (#161) Aug 23, 2018
public abstract class MyDependencyResolver : IMutableDependencyResolver
{
public abstract object GetService(Type serviceType, string contract = null);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm.. may want to provide a reference implementation to having a Dictionary even of items etc.

Copy link
Contributor

@worldbeater worldbeater Aug 23, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or maybe we should provide a production-ready custom dependency resolver implementation for a trendy DI container, like SimpleInjector or DryIoc that are loved by mobile developers for performance 🤔

Copy link
Member Author

@RLittlesII RLittlesII Aug 23, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Specifically for the GetService method or for the entire implementation? I struggled with this primarily because I don't want to affect peoples design decisions too much. I could technically just rip the guts from ModernDependencyResolver that way if they copy/paste from the website, they will at least be baseline.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@worldbeater I actually wrote this last night while I was implementing this for Autofac. I could provide that.

Copy link
Contributor

@worldbeater worldbeater Aug 23, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RLittlesII it'd be great! Autofac is an extremely popular DI container so we may attract more people by saying RxUI supports it

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to an implementation of an AutofacDependencyResolver

Copy link
Contributor

@worldbeater worldbeater Aug 24, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to an implementation of an AutofacDependencyResolver

Could we have a look?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest we put one popular DI engine in for the moment, then expand as people add more. Eg SimpleInjector etc.

protected IMyContainer Container;

public MyDepedencyResolver(IMyContainer container)
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potentially you might want to talk about InitializeReactiveUI which will re-register all the IPlatformsRegister stuff into the new container.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding something here is fine. There needs to be some verbiage on the site about those methods and what they do, which I think is beyond the scope of this page.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I am going to go into a full run down how the internals of that work.

@RLittlesII
Copy link
Member Author

@glennawatson @worldbeater Updated with an Autofac implementation.

@RLittlesII RLittlesII dismissed glennawatson’s stale review August 24, 2018 19:18

Made requested changes. Please review again.


```csharp
public class AutofacDependencyResolver : IMutableDependencyResolver
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth fixing spacing issues :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@worldbeater fixed

Copy link
Contributor

@worldbeater worldbeater Aug 24, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't find the "Approve" button, but I approve. 👍

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve button is under the top right in the "Changes" screen.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Under Review Changes

@RLittlesII RLittlesII requested a review from worldbeater August 24, 2018 19:40
```csharp
var resolver = new AutofacDependencyResolver(container);
resolver.InitializeSplat();
resolver.InitializeReactiveUI();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a comment something like

// These Initialize methods will add to your new container dependencies required by ReactiveUI
// and these must be present if you override with your own Locator.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

@worldbeater worldbeater merged commit ba46819 into reactiveui:master Aug 24, 2018
@RLittlesII RLittlesII deleted the override-di branch August 24, 2018 20:36
@lock lock bot locked and limited conversation to collaborators Jun 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Documentation: How to support DI containers other than Splat
3 participants