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

Optimize ResolverOverride #202

Open
ENikS opened this issue Jun 2, 2020 · 0 comments
Open

Optimize ResolverOverride #202

ENikS opened this issue Jun 2, 2020 · 0 comments
Assignees
Labels
Breaking change ❕ This change breaks public API Enhancement 🔨 Improvement of existing features

Comments

@ENikS
Copy link
Contributor

ENikS commented Jun 2, 2020

ResolverOverride

During resolution, types derived from ResolverOverride are used to provide dependency values that override those resolved from the container.

Problem

public abstract class ResolverOverride
{
   . . .
    public virtual ResolveDelegate<TContext> GetResolver<TContext>(Type type)
        where TContext : IResolveContext
    {
        // Resolver factory code here
    }
  . . .
}

The original design was to require a GetResolver call with the required Type, and if it matched, the resolver was returned. Calling the resolver returned the appropriate value. The override instance was deciding if it held the appropriate value and if it matched the required type. In version 5.x, this logic was moved into the container, making this approach obsolete. But, it is still uses two method calls to get the value.

Solution

The ResolverOverride class no longer implements method GetResolver. Instead it implements IResolve interface directly and provides held value in one step.

@ENikS ENikS self-assigned this Jun 2, 2020
ENikS referenced this issue Jun 3, 2020
@ENikS ENikS transferred this issue from unitycontainer/abstractions Sep 26, 2020
@ENikS ENikS changed the title ResolverOverride not implementing IResolve interface. Optimize ResolverOverride Sep 27, 2020
@ENikS ENikS transferred this issue from unitycontainer/container Mar 12, 2023
@ENikS ENikS added Enhancement 🔨 Improvement of existing features Breaking change ❕ This change breaks public API labels Mar 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Breaking change ❕ This change breaks public API Enhancement 🔨 Improvement of existing features
Projects
None yet
Development

No branches or pull requests

1 participant