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

Feature-based Injection #335

Merged
merged 31 commits into from
Feb 9, 2024

Conversation

zhiyuanliang-ms
Copy link
Contributor

@zhiyuanliang-ms zhiyuanliang-ms commented Dec 19, 2023

This PR is targeting on the potential user case is to inject services based on variants. For example, if the variant was an algorithm name, and a controller constructor took IHashAlgorithm as a constructor parameter. How could we make it so that the implementation was dependent upon an assigned variant?

Also, it tries to resolve #39.

This draft PR provides one APIs: FeatureManagementBuilder.AddFeaturedService<TService>

Example usage can be found here: examples/FeatureBasedInjectionPOC/Program.cs

Open to suggestion for the design of feature-based injection.

@zhiyuanliang-ms zhiyuanliang-ms changed the title Feature-based injection Feature-based Injection Dec 19, 2023
@zhiyuanliang-ms zhiyuanliang-ms force-pushed the zhiyuanliang/feature-based-injection branch from b28615c to a7b8f0f Compare January 18, 2024 15:57
@zhiyuanliang-ms zhiyuanliang-ms marked this pull request as ready for review January 19, 2024 05:26
@zhiyuanliang-ms zhiyuanliang-ms force-pushed the zhiyuanliang/feature-based-injection branch from d5079b3 to 6eb165f Compare January 19, 2024 06:20
@zhiyuanliang-ms zhiyuanliang-ms force-pushed the zhiyuanliang/feature-based-injection branch from 596332d to f48767c Compare January 22, 2024 05:14
@zhiyuanliang-ms
Copy link
Contributor Author

An exception should be thrown if there are multiple IVariantServiceProvider<TService> being registered.

Copy link
Member

@jimmyca15 jimmyca15 left a comment

Choose a reason for hiding this comment

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

2 unresolved minor comments on my end. Everything else looks good. Thanks @zhiyuanliang-ms !

@zhiyuanliang-ms zhiyuanliang-ms force-pushed the zhiyuanliang/feature-based-injection branch from 044ada8 to cbda0c6 Compare February 9, 2024 09:03
@zhiyuanliang-ms zhiyuanliang-ms merged commit 613380b into preview Feb 9, 2024
2 checks passed
@zhiyuanliang-ms zhiyuanliang-ms deleted the zhiyuanliang/feature-based-injection branch February 21, 2024 08:37
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.

None yet

5 participants