次の方法で共有


IPreferencesService.GetPreferencesStore メソッド

定義

指定した識別子に関連付けられている基本設定ストア インスタンスを返します。

オーバーロード

GetPreferencesStore(Guid)

指定した識別子に関連付けられている基本設定ストア インスタンスを返すか、ストアがまだ存在しない場合は新しい空のストアを作成します。

GetPreferencesStore(Guid, PreferencesStore)

指定した識別子に関連付けられている基本設定ストア インスタンスが存在する場合は、そのインスタンスを返します。

GetPreferencesStore(Guid)

指定した識別子に関連付けられている基本設定ストア インスタンスを返すか、ストアがまだ存在しない場合は新しい空のストアを作成します。

public:
 Microsoft::Web::Management::Client::PreferencesStore ^ GetPreferencesStore(Guid storeIdentifier);
public Microsoft.Web.Management.Client.PreferencesStore GetPreferencesStore (Guid storeIdentifier);
abstract member GetPreferencesStore : Guid -> Microsoft.Web.Management.Client.PreferencesStore
Public Function GetPreferencesStore (storeIdentifier As Guid) As PreferencesStore

パラメーター

storeIdentifier
Guid

ユーザー設定ストア識別子。

戻り値

指定した識別子に関連付けられている基本設定ストア インスタンス。

次の例では、基本設定ストアを保存して読み込みます。

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}");
/// <summary>
/// Load the list of features using the PreferencesServices
/// </summary>
private void LoadPreferences() {
    IPreferencesService preferences = (IPreferencesService)
        _serviceProvider.GetService(typeof(IPreferencesService));
    PreferencesStore store =
        preferences.GetPreferencesStore(PreferencesKey);
    if (store.IsEmpty) {
        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;
} 

注釈

ストアがまだ存在しない場合、このオーバーロードによって新しい空のストアが作成されます。

適用対象

GetPreferencesStore(Guid, PreferencesStore)

指定した識別子に関連付けられている基本設定ストア インスタンスが存在する場合は、そのインスタンスを返します。

public:
 bool GetPreferencesStore(Guid storeIdentifier, [Runtime::InteropServices::Out] Microsoft::Web::Management::Client::PreferencesStore ^ % store);
public bool GetPreferencesStore (Guid storeIdentifier, out Microsoft.Web.Management.Client.PreferencesStore store);
abstract member GetPreferencesStore : Guid *  -> bool
Public Function GetPreferencesStore (storeIdentifier As Guid, ByRef store As PreferencesStore) As Boolean

パラメーター

storeIdentifier
Guid

ユーザー設定ストア識別子。

store
PreferencesStore

ユーザー設定ストア (存在する場合)。

戻り値

true 基本設定ストアが存在する場合は 。それ以外の場合は false

次の例では、基本設定ストアを保存して読み込みます。

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;
} 

注釈

基本設定ストアが存在しない場合、このオーバーロードでは新しいストアは作成されません。

適用対象