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

Remove obsolete class TypeBasedOverride #201

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

Remove obsolete class TypeBasedOverride #201

ENikS opened this issue Jun 3, 2020 · 0 comments
Assignees
Labels
Enhancement 🔨 Improvement of existing features release Release branch
Milestone

Comments

@ENikS
Copy link
Contributor

ENikS commented Jun 3, 2020

Description

Class TypeBasedOverride allows targeting overrides to specific type. It creates a wrapper around regular ResolverOverride instance and sets Target during initialization.

Problem

This design creates performance and memory overhead during execution.

Solution

Type ResolverOverride has built in mechanisms to target specific type. The target could be specified either by passing Target parameter to constructor or by calling OnType() method.

// Wrong way
            var param = new ParameterOverride("injectedObject", overrideValue);
            var decorator = new TypeBasedOverride(typeof(TheType), param);

            var result = container.Resolve<IForToUndergoeInject>(decorator);

// Correct way
            var param = new ParameterOverride("injectedObject", overrideValue).OnType<TheType>();
            var result = container.Resolve<IForToUndergoeInject>(param);

Impact

Legacy code requires refactoring.

@ENikS ENikS self-assigned this Jun 3, 2020
@ENikS ENikS transferred this issue from unitycontainer/abstractions Jun 3, 2020
@ENikS ENikS added the Enhancement 🔨 Improvement of existing features label Jun 3, 2020
@ENikS ENikS added this to the 6.0.0 milestone Jun 3, 2020
@ENikS ENikS transferred this issue from unitycontainer/container Mar 12, 2023
ENikS added a commit that referenced this issue Mar 16, 2023
@github-actions github-actions bot added the release Release branch label Mar 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement 🔨 Improvement of existing features release Release branch
Projects
None yet
Development

No branches or pull requests

1 participant