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 requirement to use marker interface #40

Open
mikechristiansenvae opened this issue Jul 15, 2022 · 0 comments
Open

Remove requirement to use marker interface #40

mikechristiansenvae opened this issue Jul 15, 2022 · 0 comments

Comments

@mikechristiansenvae
Copy link

mikechristiansenvae commented Jul 15, 2022

It would be nice if I wasn't required to use the IWpfShell marker interface to have the startup window. This requirement means that specific Window is special, and it is so at compile time. Using attributes has similar problems.

As an alternative, consider if there was an IStartupWindowFactory interface, whose duty was to provide a list of startup Window. It could provide different Window based on whatever factors the developer chooses.

The default implementation of IStartupWindowFactory could use the current IWpfShell marker interface, making it a drop-in replacement.

See this repository / diff showing one way it could be done.

  • You can see that the IWpfShell interface has been removed from the window. (Source)
  • A default implementation of IStartupWindowFactory is included that uses IWpfShell. Since it's using TryAddSingleton, it will be added if and only if the user has not already added their own implementation. (Source)
  • This shows the default implementation of IStartupWindowFactory. With this implementation there is no change in behavior from current. (Source)
  • This shows how the user would create a custom IStartupWindowFactory (Source)
  • This shows how the user would add that custom IStartupWindowFactory. Since it's using AddSingleton, it's going to override the default factory that was added with TryAddSingleton. (Source)
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

No branches or pull requests

1 participant