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

Replace with static class instead of dependency injection #1

Open
Daltz333 opened this issue Apr 23, 2023 · 3 comments
Open

Replace with static class instead of dependency injection #1

Daltz333 opened this issue Apr 23, 2023 · 3 comments

Comments

@Daltz333
Copy link

Issue title is pretty self explanatory. The use of dependency injection for no (obvious?) reason makes this library cumbersome to use in existing projects.

@sandreas
Copy link
Owner

Issue title is pretty self explanatory. The use of dependency injection for no (obvious?) reason makes this library cumbersome to use in existing projects.

Thanks for your request and you are absolutely correct... Furthermore it is unfortunately incompatible with existing Apis (like WPF or Maui).

It's my first Avalonia-Lib, and I plan to make it more convenient and compatible in the future, but for now I unfortunately don't have the time... I'll try to improve asap.

@Daltz333
Copy link
Author

No worries! My recommendation if you can't create statics is a singleton that requires calling an Init() function. So something like

In App.xaml.cs

Preferences.Init();

To use

Preferences.Get("Key", fallback);

@sandreas
Copy link
Owner

sandreas commented Feb 9, 2025

@Daltz333
Reworked this due to interface incompatibilties. Also added Browser support.

There you go:
https://www.nuget.org/packages/Sandreas.Avalonia.SimplePreferences

Documentation:
https://github.com/sandreas/Avalonia.SimplePreferences

Early state but should mostly work like expected, feedback is welcome!

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

2 participants