当前位置: 首页>>代码示例>>C#>>正文


C# LiveAuthClient.Logout方法代码示例

本文整理汇总了C#中Microsoft.Live.LiveAuthClient.Logout方法的典型用法代码示例。如果您正苦于以下问题:C# LiveAuthClient.Logout方法的具体用法?C# LiveAuthClient.Logout怎么用?C# LiveAuthClient.Logout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Live.LiveAuthClient的用法示例。


在下文中一共展示了LiveAuthClient.Logout方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SignOutButton_OnClick

		private async void SignOutButton_OnClick(object sender, RoutedEventArgs e)
		{
			try
			{
				// Initialize access to the Live Connect SDK.
				LiveAuthClient LCAuth = new LiveAuthClient();
				LiveLoginResult LCLoginResult = await LCAuth.InitializeAsync();
				// Sign the user out, if he or she is connected;
				//  if not connected, skip this and just update the UI
				if (LCLoginResult.Status == LiveConnectSessionStatus.Connected)
				{
					LCAuth.Logout();
				}

				// At this point, the user should be disconnected and signed out, so
				//  update the UI.
				var loader = new Windows.ApplicationModel.Resources.ResourceLoader();
				this.UserNameTextBlock.Text = loader.GetString("MicrosoftAccount/Text");

				// Show sign-in button.
				SignInButton.Visibility = Visibility.Visible;
				SignOutButton.Visibility = Visibility.Collapsed;
			}
			catch (LiveConnectException x)
			{
				// Handle exception.
			}
		}
开发者ID:vapps,项目名称:Modern_LiveBoard,代码行数:28,代码来源:AccountSettingsFlyout.xaml.cs

示例2: SignOutClick

        private async void SignOutClick(object sender, RoutedEventArgs e)
        {
            try
            {
                // Initialize access to the Live Connect SDK.
                LiveAuthClient LCAuth = new LiveAuthClient();
                LiveLoginResult LCLoginResult = await LCAuth.InitializeAsync();
                // Sign the user out, if he or she is connected;
                //  if not connected, skip this and just update the UI
                if (LCLoginResult.Status == LiveConnectSessionStatus.Connected)
                {
                    
                    LCAuth.Logout();
                }

                // At this point, the user should be disconnected and signed out, so
                //  update the UI.
                this.userName.Text = "You're not signed in.";
                Connection.User = null;
                // Show sign-in button.
                signInBtn.Visibility = Windows.UI.Xaml.Visibility.Visible;
                signOutBtn.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                new MessageDialog("The app is exiting since you are no longer logged in.").ShowAsync();
                App.Current.Exit();
            }
            catch (LiveConnectException x)
            {
                // Handle exception.
            }
        }
开发者ID:Zainabalhaidary,项目名称:Clinic,代码行数:30,代码来源:Account.xaml.cs

示例3: SignOutClick

        private async void SignOutClick(object sender, RoutedEventArgs e)
        {
            try
            {
                // Initialize access to the Live Connect SDK.
                LiveAuthClient LCAuth = new LiveAuthClient();
                LiveLoginResult LCLoginResult = await LCAuth.InitializeAsync();
                // Sign the user out, if he or she is connected;
                //  if not connected, skip this and just update the UI
                if (LCLoginResult.Status == LiveConnectSessionStatus.Connected)
                {
                    LCAuth.Logout();
                }

                // At this point, the user should be disconnected and signed out, so
                //  update the UI.
                this.userName.Text = "You're not signed in.";

                // Show sign-in button.
                signInBtn.Visibility = Windows.UI.Xaml.Visibility.Visible;
                signOutBtn.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
            }
            catch (LiveConnectException x)
            {
                // Handle exception.
                this.userName.Text = x.Message.ToString();
                throw new NotImplementedException();
            }
        }
开发者ID:violabazanye,项目名称:BudgetWise,代码行数:29,代码来源:Account.xaml.cs

示例4: Authenticate

        /// <summary>
        /// Login mit einem entsprechenden Dialog.
        /// </summary>
        /// <returns>Ein MobileServiceUser, der awaited werden kann oder null bei Misserfolg.</returns>
        internal async static Task<MobileServiceUser> Authenticate(MobileServiceClient mobileService)
        {
            LiveAuthClient liveAuthClient = new LiveAuthClient(APIKeys.LiveClientId);
            var source = new TaskCompletionSource<MobileServiceUser>();

            liveAuthClient.Logout();

            var scopes = new string[] { "wl.basic", "wl.offline_access", "wl.signin" };
            App.Current.RootVisual.Visibility = System.Windows.Visibility.Collapsed;

            try
            {
                session = (await liveAuthClient.LoginAsync(scopes)).Session;
            }
            finally
            {
                App.Current.RootVisual.Visibility = System.Windows.Visibility.Visible;
            }
            return await mobileService.LoginWithMicrosoftAccountAsync(session.AuthenticationToken);

        }
开发者ID:JulianMH,项目名称:DoIt,代码行数:25,代码来源:LiveAuthenticator.cs

示例5: Authenticate

        private async System.Threading.Tasks.Task Authenticate()
        {
            LiveAuthClient liveIdClient = new LiveAuthClient("https://sendit.azure-mobile.net/");


            while (session == null)
            {
                // Force a logout to make it easier to test with multiple Microsoft Accounts
                if (liveIdClient.CanLogout)
                    liveIdClient.Logout();


                LiveLoginResult result = await liveIdClient.LoginAsync(new[] { "wl.basic" });
                if (result.Status == LiveConnectSessionStatus.Connected)
                {
                    session = result.Session;
                    LiveConnectClient client = new LiveConnectClient(result.Session);
                    LiveOperationResult meResult = await client.GetAsync("me");
                    MobileServiceUser loginResult = await App.MobileService.LoginAsync(result.Session.AuthenticationToken);


                    string title = string.Format("Welcome {0}!", meResult.Result["first_name"]);
                    var message = string.Format("You are now logged in - {0}", loginResult.UserId);
                    var dialog = new MessageDialog(message, title);
                    dialog.Commands.Add(new UICommand("OK"));
                    await dialog.ShowAsync();
                }
                else
                {
                    session = null;
                    var dialog = new MessageDialog("You must log in.", "Login Required");
                    dialog.Commands.Add(new UICommand("OK"));
                    await dialog.ShowAsync();
                }
            }


        }
开发者ID:Hitchhikrr,项目名称:Win8Hackathon,代码行数:38,代码来源:MainPage.xaml.cs

示例6: Authenticate

        public async Task Authenticate()
        {
            // For Microsoft ID to work in Windows 8, you need to associate the Windows 8 app
            // with a Windows 8 Store app (ie: create an app in the Store/reserve a name)
            // you do not need to publish the app to test

            var liveIdClient = new LiveAuthClient("https://headstails.azure-mobile.net/");

            while (App.liveConnectSession == null)
            {
                // Force a logout to make it easier to test with multiple Microsoft Accounts
                if (liveIdClient.CanLogout)
                    liveIdClient.Logout();

                CurrentLoginStatus = "Connecting to Microsoft Services";

                // as per: http://stackoverflow.com/questions/17938828/obtaining-the-users-email-address-from-the-live-sdk

                var result = await liveIdClient.LoginAsync(new[] { "wl.emails" });
                if (result.Status == LiveConnectSessionStatus.Connected)
                {
                    CurrentLoginStatus = "Connected to Microsoft Services";
                    App.liveConnectSession = result.Session;
                    var client = new LiveConnectClient(result.Session);
                    microsoftAccountLoggedInUser = await client.GetAsync("me");

                    CurrentLoginStatus = "Getting Microsoft Account Details";
                    mobileServiceLoggedInUser = await App.MobileService.LoginWithMicrosoftAccountAsync(result.Session.AuthenticationToken);
                    
                    var remoteLeaderBoard = App.MobileService.GetTable<Leaderboard>();
                    remoteLeaderBoard = App.MobileService.GetTable<Leaderboard>();

                    CurrentLoginStatus = string.Format("Welcome {0}!", microsoftAccountLoggedInUser.Result["name"]);
                    userName = microsoftAccountLoggedInUser.Result["name"].ToString();

                    await Task.Delay(2000); // non-blocking Thread.Sleep for 2000ms (2 seconds)

                    CurrentlyLoggedIn = true; // this will then flip the bit that shows the different UI for logged in
                }
                else
                {
                    CurrentLoginStatus = "Y U NO LOGIN?";
                    CurrentlyLoggedIn = false;
                }
            }
        }
开发者ID:nickhodge,项目名称:HeadsTails,代码行数:46,代码来源:HeadsTailsUserDetailsModel.cs

示例7: DisconnectAsync

        public async Task DisconnectAsync()
        {
            var cl = new LiveAuthClient(CLIENT_ID);

            await cl.Initialize();

            if (cl.Session != null)
            {
                cl.Logout();
            }
        }
开发者ID:SNSB,项目名称:DiversityMobile,代码行数:11,代码来源:CloudStorageService.cs

示例8: SignOut

 // Remove user and record
 public void SignOut()
 {
     LiveAuthClient liveAuthClient = new LiveAuthClient(LIVE_CLIENT_ID);
     liveAuthClient.Logout();
     App.ApplicationSettings.Remove(ONE_DRIVE_SIGN_IN_KEY);
     StorageExplorer.RemoveKey(this.GetStorageName());
     this.LiveClient = null;
     this.CurrentAccount = null;
 }
开发者ID:pinthecloud,项目名称:pin_the_cloud_ws,代码行数:10,代码来源:OneDriveManager.cs

示例9: Logout

 /// <summary>
 /// Loggt den aktuellen Nutzer aus.
 /// </summary>
 internal static void Logout()
 {
     LiveAuthClient liveAuthClient = new LiveAuthClient(APIKeys.LiveClientId);
     liveAuthClient.Logout();
 }
开发者ID:JulianMH,项目名称:DoIt,代码行数:8,代码来源:LiveAuthenticator.cs

示例10: Authenticate

        public async Task Authenticate()
        {
            var liveIdClient = new LiveAuthClient();

            while (_session == null)
            {
                //
                // ToDo: Determine if this code is necessary:
                // Force a logout to make it easier to test with multiple Microsoft Accounts
                //

                if (liveIdClient.CanLogout)
                    liveIdClient.Logout();


                LiveLoginResult result = await liveIdClient.LoginAsync(new[] {"wl.basic", "wl.emails"});
                if (result.Status == LiveConnectSessionStatus.Connected)
                {
                    _session = result.Session;
                    var client = new LiveConnectClient(result.Session);
                    LiveOperationResult meResult = await client.GetAsync("me");
                    dynamic dynamicResult = meResult.Result;

                    string userName = "";
                    string email = "";

                    try
                    {
                        userName = string.Format("{0} {1}", dynamicResult.first_name, dynamicResult.last_name);
                        email = dynamicResult.emails.preferred;
                        Settings.EmailAddress = email;
                        //Settings.EmailAddress = "[email protected]";

                        var roomManager = RoomManager.GetInstance();
                        roomManager.AddMemberToRoom(Settings.userInstance);
                        roomManager.ChangeRoomHost(Settings.userInstance);
                    }
                    catch
                    {
                        // Todo: determine what to do here if this fails...
                    }

                    var mainPageViewModel = MainPageViewModel.GetInstance();
                    mainPageViewModel.UserName = string.Format("Welcome {0}!", meResult.Result["first_name"]);

                }
                else
                {
                    _session = null;
                    var dialog = new MessageDialog("You must log in.", "Login Required");
                    dialog.Commands.Add(new UICommand("OK"));
                    await dialog.ShowAsync();
                }
            }
        }
开发者ID:jonathanyeung,项目名称:ozwego,代码行数:55,代码来源:ServerProxy.cs

示例11: Disconnect

        public void Disconnect() {
            var cl = new LiveAuthClient("00000000480F4F1E");

            cl.Logout();
        }
开发者ID:rollingthunder,项目名称:DiversityMobile,代码行数:5,代码来源:CloudStorageService.cs

示例12: Cleanup

        public override void Cleanup()
        {

            var aC = new LiveAuthClient(ClientId, RedirectUri);
            aC.Logout();
            base.Cleanup();
        }
开发者ID:Hitchhikrr,项目名称:WP7-RMM-Project,代码行数:7,代码来源:LiveSignInViewModel.cs


注:本文中的Microsoft.Live.LiveAuthClient.Logout方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。