-
-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #213 from hadashiA/ku/register-instance-as-external
Make sure that RegisterInstance is not managed by the container
- Loading branch information
Showing
12 changed files
with
138 additions
and
94 deletions.
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
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
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
36 changes: 36 additions & 0 deletions
36
VContainer/Assets/VContainer/Runtime/Unity/InstanceComponentRegistration.cs
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,36 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace VContainer.Unity | ||
{ | ||
sealed class InstanceComponentRegistration : IRegistration | ||
{ | ||
public Type ImplementationType { get; } | ||
public IReadOnlyList<Type> InterfaceTypes { get; } | ||
public Lifetime Lifetime => Lifetime.Singleton; | ||
|
||
readonly object instance; | ||
readonly IReadOnlyList<IInjectParameter> parameters; | ||
readonly IInjector injector; | ||
|
||
public InstanceComponentRegistration( | ||
object instance, | ||
Type implementationType, | ||
IReadOnlyList<Type> interfaceTypes, | ||
IReadOnlyList<IInjectParameter> parameters, | ||
IInjector injector) | ||
{ | ||
ImplementationType = implementationType; | ||
InterfaceTypes = interfaceTypes; | ||
this.instance = instance; | ||
this.parameters = parameters; | ||
this.injector = injector; | ||
} | ||
|
||
public object SpawnInstance(IObjectResolver resolver) | ||
{ | ||
injector.Inject(instance, resolver, parameters); | ||
return instance; | ||
} | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
VContainer/Assets/VContainer/Runtime/Unity/InstanceComponentRegistration.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
Oops, something went wrong.
ac26b0f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: