-
Notifications
You must be signed in to change notification settings - Fork 127
Feature filter parameter object #589
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -21,6 +21,12 @@ public class FeatureFilterEvaluationContext | |||||
| /// </summary> | ||||||
| public IConfiguration Parameters { get; set; } | ||||||
|
|
||||||
| /// <summary> | ||||||
| /// A strongly-typed parameter object, if any, provided by a custom <see cref="IFeatureDefinitionProvider"/>. | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| /// When set, feature filters should prefer this over <see cref="Parameters"/>. | ||||||
| /// </summary> | ||||||
| public object ParameterObject { get; set; } | ||||||
|
|
||||||
| /// <summary> | ||||||
| /// A settings object, if any, that has been pre-bound from <see cref="Parameters"/>. | ||||||
| /// The settings are made available for <see cref="IFeatureFilter"/>s that implement <see cref="IFilterParametersBinder"/>. | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -68,8 +68,10 @@ public Task<bool> EvaluateAsync(FeatureFilterEvaluationContext context, ITargeti | |
| } | ||
|
|
||
| // | ||
| // Check if prebound settings available, otherwise bind from parameters. | ||
| TargetingFilterSettings settings = (TargetingFilterSettings)context.Settings ?? (TargetingFilterSettings)BindParameters(context.Parameters); | ||
| // Check if ParameterObject available (takes precedence), then prebound settings, otherwise bind from parameters. | ||
| TargetingFilterSettings settings = context.ParameterObject != null | ||
| ? (TargetingFilterSettings)context.ParameterObject | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider the exception that will be raised by the system if someone provides the incorrect type here. Ideally we'd like a |
||
| : (TargetingFilterSettings)context.Settings ?? (TargetingFilterSettings)BindParameters(context.Parameters); | ||
|
|
||
| return Task.FromResult(TargetingEvaluator.IsTargeted(targetingContext, settings, _options.IgnoreCase, context.FeatureName)); | ||
| } | ||
|
|
||
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.