You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
Currently Application is almost completely static methods and properties. This prevents defining alternative implementations and tests cannot Moq expectations of the static methods their members invoke.
Describe the solution you'd like
Change all Application methods to not be static (adding virtual where it makes sense)
Implement Singleton pattern i.e. everyone accesses Application.Instance which is an IApplication
Update all call sites
This will enable adding alternative implementations to IApplication e.g. #3837
To do this I could for example subclass Application but override certain methods, or implement IApplication from scratch. We would then change the instance in Program.cs (i.e. at start of program)
// This would throw unless the current instance is Shutdown or not yet InitApplication.ChangeInstance(myAltApplicationClass)
Describe alternatives you've considered
An alternative is to keep public API how it is and add the singleton pattern behind the static methods i.e. the static methods all forward to an internal singleton. This would be more code to write but would look prettier for the user.
Additional context
Add any other context or screenshots about the feature request here.
The text was updated successfully, but these errors were encountered:
An alternative is to keep public API how it is and add the singleton pattern behind the static methods i.e. the static methods all forward to an internal singleton. This would be more code to write but would look prettier for the user.
But this means you have 4+ copies of each method signature
In Interface IApplication
In static form on Application
In ApplicationImpl class - the one that implements IApplication and gets hosted as the singleton instance
In any derrived/alternative IApplication class
You also want the xmldoc on the statics and the IApplication members as they wont benefit from <inheritdoc/>
Still its probably the cleanest for external library user perspective.
Is your feature request related to a problem? Please describe.
Currently
Application
is almost completely static methods and properties. This prevents defining alternative implementations and tests cannot Moq expectations of the static methods their members invoke.Describe the solution you'd like
Application.Instance
which is an IApplicationThis will enable adding alternative implementations to IApplication e.g. #3837
To do this I could for example subclass Application but override certain methods, or implement IApplication from scratch. We would then change the instance in Program.cs (i.e. at start of program)
Describe alternatives you've considered
An alternative is to keep public API how it is and add the singleton pattern behind the static methods i.e. the static methods all forward to an internal singleton. This would be more code to write but would look prettier for the user.
Additional context
Add any other context or screenshots about the feature request here.
The text was updated successfully, but these errors were encountered: