C# omAppSettings:应用程序设置库 { 公共ISettings设置{get;set;} 公共重写对象此[string propertyName] { 得到 { 返回此.Settings.Values[propertyName]; } 设置 { this.Settings.Values[propertyName]=值; } } //我相信这个课程会有更多的实现工作 }

C# omAppSettings:应用程序设置库 { 公共ISettings设置{get;set;} 公共重写对象此[string propertyName] { 得到 { 返回此.Settings.Values[propertyName]; } 设置 { this.Settings.Values[propertyName]=值; } } //我相信这个课程会有更多的实现工作 },c#,settings,mef,application-settings,composite,C#,Settings,Mef,Application Settings,Composite,此外,您还需要为ISetting实例提供序列化机制 编辑:修复了一些代码语法错误 public class AppData : ApplicationSettingsBase { [UserScopedSetting()] [DefaultSettingValue("true")] public bool Clipboard { get { return ((bool)this["Clipboard"]); } set { this["Clipboard"] =

此外,您还需要为ISetting实例提供序列化机制

编辑:修复了一些代码语法错误

public class AppData : ApplicationSettingsBase
{
  [UserScopedSetting()]
  [DefaultSettingValue("true")]
  public bool Clipboard
  {
    get { return ((bool)this["Clipboard"]); }
    set { this["Clipboard"] = (bool)value; }
  }
}
public class AppData : ISettings
{ 
    Setting Clipboard = new Setting();
    Clipboard.Scope = SettingScope.User;
    Clipboard.SettingType = List<String>;

    List<String> DefaultClipboards = new List<String>();
    DefaultClipboards.Add("FoxClipboard");
    Clipboard.DefaultSetting = DefaultClipboards;
}
public interface ISettings
{
    Dictionary<string,object> Values{ get; set; }

    public object GetDefaultValue(string key);

    // Whatever else you might need
}

public class CustomAppSettings : ApplicationSettingsBase
{
    public ISettings Settings { get; set; }

    public override object this[string propertyName]
    {
        get
        {
            return this.Settings.Values[propertyName];
        }
        set
        {
            this.Settings.Values[propertyName] = value;
        }
    }

    // There will be more implementation work for this class I'm sure
}