数组的applicationSettings:保存列表或使用自定义类
public class Setting<T>
{
string name;
T value;
T defaultValue;
bool hasValue;
public Setting(string name, T defaultValue)
{
this.name = name;
this.defaultValue = defaultValue;
}
public T Value
{
get
{
//checked for cached value
if (!this.hasValue)
{
//try to get value from isolated storage
if (!IsolatedStorageSettings.ApplicationSettings.TryGetValue(this.name, out this.value))
{
//not set yet
this.value = this.defaultValue;
IsolatedStorageSettings.ApplicationSettings[this.name] = this.value;
}
this.hasValue = true;
}
return this.value;
}
set
{
//save value to isolated storage
IsolatedStorageSettings.ApplicationSettings[this.name] = value;
this.value = value;
this.hasValue = true;
}
}
public T DefaultValue
{
get { return this.defaultValue; }
}
//clear cached value;
public void ForceRefresh()
{
this.hasValue = false;
}
}
,然后在一个单独的类:
公共静态类设置 {从设置菜单 //用户设置
public static readonly Setting<bool> IsAerialMapStyle = new Setting<bool>("IsAerialMapStyle", false);
}
这一切工作正常,但我不能解决如何将数组或长度为24的列表保存到使用此方法的应用程序设置。
我有这个至今:
public static readonly Setting<List<bool>> ListOpened = new Setting<List<bool>>("ListOpened",....
任何帮助,将不胜感激!