數組的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",....
任何幫助,將不勝感激!