-
Notifications
You must be signed in to change notification settings - Fork 391
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
Add Rules from code #7685
Add Rules from code #7685
Conversation
Define a type that defines `Rule` instances in code (rather than loading them from XAML) and dynamically adds and removes them from the project based on capabilities.
This PR is just for the purposes of discussion; this should never be merged. |
<value>My In-Memory Page 😀</value> | ||
</data> | ||
<data name="MyPropertyPage_PropertyDescription" xml:space="preserve"> | ||
<value>🎉 Put anything you want here! It doesn't matter! 🎉</value> |
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.
Do we display emojis in the UI? :)
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.
Yes! Though WPF doesn't color them.
_additionalRuleDefinitionsService.AddRuleDefinition(_rule.Value, context: "Project"); | ||
|
||
return Task.CompletedTask; | ||
} |
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.
If you were doing this for real, you'd want to setup a direct data flow relationship between the capability change and the resulting rules. Otherwise, this is going to result in situations where the project and the rules associated with it are out of sync. You would do that by exporting IAdditionalRuleDefinitionsService and have AdditionalRuleDefinitions property return a data source that changed based on the capabilities changing (you'd need to delegate/listen to underlying IAdditionalRuleDefinitionsService as there can only be one).
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.
We would want to create a new IAdditionalRuleDefinitionsService
implementation anyway (or augment the existing one) in order to simplify the experience for anyone wishing to create Rule
s in this manner. Ideally, they would just associate a set of Rule
s with a capability condition, and the underlying service would handle capability changes and pushing information through the data flow.
Is it possible to replace the IAdditionalRuleDefinitionsService
with a new one? The interface is defined as:
[ProjectSystemContract(ProjectSystemContractScope.UnconfiguredProject, ProjectSystemContractProvider.System)]
public interface IAdditionalRuleDefinitionsService : IProjectValueDataSource<IAdditionalRuleDefinitions>
{
...
}
So there's only supposed to be exactly one per unconfigured project. Would it be possible to MEF-export a different implementation that would replace it?
This approach has been superceded by |
Define a type that defines
Rule
instances in code (rather than loading them from XAML) and dynamically adds and removes them from the project based on capabilities.Microsoft Reviewers: Open in CodeFlow