.NET設定メカニズムを参照して、this質問への回答のいくつかに触発されて、別のラッパークラス(おそらくシングルトン)を介して設定の使用をラッピングする人がいるようです。設定を直接使用するか、ラッパークラスを使用しますか?
設定クラスは既にシングルトンではありませんか?
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "9.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
// rest of class...
}
。
。
。代わりに、必要な場合、直接これを行うの
int foo = MySettingsWrapper.MyInt;
:依存性注入の
int foo = Settings.Default.MyInt;