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

Add support for IServiceLocator / IServiceProvider Scope. #231

Merged
merged 9 commits into from
Dec 5, 2019
Merged

Conversation

mayuki
Copy link
Member

@mayuki mayuki commented Nov 26, 2019

Add support for IServiceLocator / IServiceProvider Scope.

  • IService<T>: Create a scope per Unary call.
  • IStreamingHub<TSelf, TReceiver>: Create a scope per StreamingHub instance.

Changes

  • Remove Register methods from IServiceLocator.
    • IServiceLocator is now provided for only resolving external types. MagicOnion doesn't register any service and types.
  • Introduce IMagicOnionServiceActivator for creating service instances.
    • For example, MagicOnion.Hosting uses ActivatorUtilities.GetServiceOrCreateInstance<T> that is also used by ASP.NET MVC Core.

Breaking changes

  • Remove IServiceLocator.Register<T>
  • Change signature of IGroupRepositoryFactory method
    • IGroupRepository CreateRepository(IServiceLocator serviceLocator); -> IGroupRepository CreateRepository(IFormatterResolver formatterResolver, IMagicOnionLogger logger, IServiceLocator serviceLocator);

@mayuki mayuki requested a review from neuecc November 26, 2019 07:55
Copy link
Member

@neuecc neuecc left a comment

Choose a reason for hiding this comment

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

It seems very good!

@mayuki mayuki merged commit e3ef908 into master Dec 5, 2019
@mayuki mayuki deleted the hotfix/DI branch December 5, 2019 10:04
AntonC9018 pushed a commit to AntonC9018/MagicOnion that referenced this pull request Sep 13, 2022
Add support for IServiceLocator / IServiceProvider Scope.
AntonC9018 pushed a commit to AntonC9018/MagicOnion that referenced this pull request Sep 13, 2022
Add support for IServiceLocator / IServiceProvider Scope.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants