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

Add UnitsNetSetup to hold global static state #2

Conversation

angularsen
Copy link

@angularsen angularsen commented May 20, 2023

I built on your recent QuantityInfoLookup and added UnitsNetSetup to gather global state in a single place as a singleton, with the possibility of passing instances of it to static methods later to override the defaults.

This way, state is no longer scattered among multiple classes that depend on each other in non-obvious ways and where initialization order has caused issues up until now.

Changes

  • Add UnitsNetSetup to hold global state as a singleton property Default that controls default state initialization.
    • Add properties for all "services" that depend on global state: UnitConverter, UnitAbbreviationsCache, UnitParser, QuantityParser
  • Forward all other Default singleton properties from these services to UnitsNetSetup.Default and mark obsolete
  • Add some TODOs where it seems functionality is missing

@angularsen angularsen closed this Jun 21, 2023
@angularsen
Copy link
Author

Moved to angularsen#1267

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.

1 participant