IPreferencesService.Save メソッド
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
環境設定を保存します。
public:
void Save();
public void Save ();
abstract member Save : unit -> unit
Public Sub Save ()
例
次の例では、ユーザー設定ストアを保存して読み込みます。
class SH {
public static int iCnt;
public static string Count { get { return "Count"; } }
public static string Entry { get { return "Entry"; } }
private static readonly Guid PreferencesKey =
new Guid("{1abb6907-6dff-1638-8323-deadbeef1638}");
private void LoadPreferences2() {
IPreferencesService preferences = (IPreferencesService)
_serviceProvider.GetService(typeof(IPreferencesService));
PreferencesStore store;
bool bExists = preferences.GetPreferencesStore(PreferencesKey, out store);
if (!bExists) {
return;
}
for (int i = 0; i < _features.Length; i++) {
MRUList<MRUPageInfo> current = _features[i];
string val = SH.Count + i.ToString();
int count = (int)store.GetValue(val, 0);
if (count <= 0) {
continue;
}
for (int j = count - 1; j >= 0; j--) {
val = SH.Entry + i.ToString() + "-" + j.ToString();
string modulePageTypeName = store.GetValue(val, null);
current.Add(new MRUPageInfo(modulePageTypeName));
}
}
}
/// <summary>
/// Store the list of features in the preference store using
/// the PreferencesServices.
/// </summary>
internal void SavePreferences() {
if (_serviceProvider != null) {
IPreferencesService preferences = (IPreferencesService)
_serviceProvider.GetService(typeof(IPreferencesService));
PreferencesStore store =
preferences.GetPreferencesStore(PreferencesKey);
for (int i = 0; i < _features.Length; i++) {
MRUList<MRUPageInfo> current = _features[i];
string val = SH.Count + i.ToString();
store.SetValue(val, current.Count, 0);
int j = 0;
foreach (MRUPageInfo info in current) {
if (info == null) {
continue;
}
val = SH.Entry + i.ToString() + "-" + j.ToString();
store.SetValue(val, info.Type, null);
j++;
}
}
preferences.Save();
}
_serviceProvider = null;
}