Answer the question
In order to leave comments, you need to log in
How to properly inject Properties.Settings into a project?
Hello.
There is a "small legacy project on WinForms". There's a little poltergeist there with settings that are Properties.Settings. In general, they began to understand and do refactoring with the removal of controls from the main project to the control libraries.
The program has settings that it uses (surprise!). Controls are also read and written (users can tick boxes through the form).
To deal with the poltergeist, they made an abstraction over Settings, an interface with all the necessary fields in the settings and Save methods, etc.
public interface ISettingProvider
{
int MyInt { get; set; }
string MyString { get; set; }
void Save();
}
public string MyString
{
get => Properties.Settings.Default.MyString;
set => Properties.Settings.Default.MyString = value;
}
mock.VerifyGet(...)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question