How to Sangachal Properties.Settings in the project?

Hi all.

There is a "small legacy project for WinForms". There is a small poltergeist with the settings Properties.Settings. In General, we began to understand and to do the refactoring with the removal of controls from the main project to the library of controls.

The program has settings that it uses (surprise!). Controls read and write (using a mold, users can put a tick).

To deal with the poltergeist made an abstraction of the above Settings, the interface with all the required fields in the settings and Save methods, and so on.

public interface ISettingProvider
 int MyInt { get; set; }
 string MyString { get; set; }

 void Save();

Accordingly, in the project there is a class for the interface through which hetero/sateri uses the settings
public string MyString
 get => Properties.Settings.Default.MyString;
 set => Properties.Settings.Default.MyString = value;

In TESTS makim interface and was looking for a request to settings.

As you know TK controls can read the settings here and there, including from proctitis with controls, although the settings are called Properties.Settings.Default are in fact different classes and controls not write the settings of the main project, and in the settings themselves.

Usually would have just passed the class as the parameter to the constructor, but they are different classes. The main project knows that there is a CL with Connolly, but the controls absolutely do not need to know about the main project. Otherwise the cross-reference.

The classic way to fight this garbage is to make the code in your own project. Library references it. Main references it. The library does not know about the main.
Resharper tells you when the setting is more than anyone not used :)

Cons-the clear (if any).

I correctly think?
June 27th 19 at 14:58

Find more questions by tags .NETC#