MVVM Pattern
Closed this issue · 4 comments
ghost1372 commented
how we can use this lib in mvvm pattern?
AndrewKeepCoding commented
I guess you can't. Do you have any specific use cases?
ghost1372 commented
I guess you can't. Do you have any specific use cases?
No, but it is useful to have it.
i think we can add service first:
.AddSingleton<ILocalizer, Localizer>()
then in MainViewModel we can initialize:
public MainViewModel(ILocalizer localizer)
{
localizer.AddStringResourcesFolderForLanguageDictionaries(StringsFolderPath);
}
I didn't test, I don't know if it works or not
AndrewKeepCoding commented
.AddSingleton<ILocalizer, Localizer>()
The code above won't work. The Localizer
is designed to be created only by the LocalizerBuilder
. Once it's created you can use it in dependency injection:
.AddSingleton<ILocalizer>(_ => Localizer.Get())
Anyway, once is initialized, you can't add dictionaries.
AndrewKeepCoding commented
Closing this as not planed.