Share via


User.NonRoamableId 속성

정의

사용자의 로밍할 수 없는 ID를 가져옵니다.

public:
 property Platform::String ^ NonRoamableId { Platform::String ^ get(); };
winrt::hstring NonRoamableId();
public string NonRoamableId { get; }
var string = user.nonRoamableId;
Public ReadOnly Property NonRoamableId As String

속성 값

String

Platform::String

winrt::hstring

사용자의 로밍할 수 없는 ID입니다.

예제

이 예제에서는 앱이 일시 중단될 때 NonRoamableId를 저장한 다음 앱이 활성화될 때 NonRoamableId를 가져오는 방법을 보여줍니다. 그런 다음 NonRoamableId를 사용하여 현재 사용자로 설정된 User 개체를 검색합니다. 이 코드는 App.xaml.cs에 배치되고 불필요한 코드가 제거되었습니다.

User ActiveUser = null;

protected async override void OnLaunched(LaunchActivatedEventArgs e)
{
    // ... code removed ...

        if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
        {
            //TODO: Load state from previously suspended application
            var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
            if (localSettings.Values.ContainsKey("previousUser"))
            {
                var previousId = (string)localSettings.Values["previousUser"];
                ActiveUser = User.GetFromId(previousId);
            }
            else
            {
                IReadOnlyList<User> users = await Windows.System.User.FindAllAsync();
                ActiveUser = users[0];
            }
        }

    // ... code removed ...
}

private void OnSuspending(object sender, SuspendingEventArgs e)
{
    var deferral = e.SuspendingOperation.GetDeferral();
    //TODO: Save application state and stop any background activity

    // If the user is authenticated and not a guest, save the  
    // NonRoamableId so we can retrieve this specific user later. 
    var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;

    if (ActiveUser != null &&
       (ActiveUser.AuthenticationStatus != UserAuthenticationStatus.Unauthenticated) &&
       (ActiveUser.Type == UserType.LocalUser || ActiveUser.Type == UserType.RemoteUser))
    {
        localSettings.Values.Add("previousUser", ActiveUser.NonRoamableId);
    }
    else
    {
        if (localSettings.Values.ContainsKey("previousUser"))
        {
            localSettings.Values.Remove("previousUser");
        }
    }

    deferral.Complete();
}

설명

다중 사용자 앱에서는 앱이 활성화 해제되거나 일시 중단되기 전에 앱이 어떤 사용자로 작업했는지 기억해야 할 수 있습니다. NonRoamableId를 저장한 다음 키로 사용하여 활성화 시 사용자 개체를 다시 검색할 수 있습니다(User.GetFromId 참조).

사용자 개체의 NonRoamableId는 디바이스, 앱 및 사용자에게 고유한 문자열입니다. 다른 디바이스 또는 다른 앱으로 로밍할 수 없습니다. 또한 사용자가 원격으로 로그인하여 User.Type 값이 다른 경우 NonRoamableId는 다릅니다.

적용 대상