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


C# Live.LiveConnectClient类代码示例

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


LiveConnectClient类属于Microsoft.Live命名空间,在下文中一共展示了LiveConnectClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: btnSignin_SessionChanged_2

 private async void btnSignin_SessionChanged_2(object sender, LiveConnectSessionChangedEventArgs e)
 {
     currentLoginType = "Microsoft";
     if (TextValidation())
     {
         lblMsg.Text = "";
         App.liveAuthClient = new LiveAuthClient(redirectURL);
         LiveLoginResult liveLoginResult = await App.liveAuthClient.LoginAsync(new string[] { "wl.signin", "wl.basic" });
         if (liveLoginResult.Session != null && liveLoginResult.Status == LiveConnectSessionStatus.Connected)
         {
             client = new LiveConnectClient(liveLoginResult.Session);
             LiveOperationResult operationResult = await client.GetAsync("me");
             dynamic pic = await client.GetAsync("me/picture");
             try
             {
                 MobileServiceUser user = await App.MobileService.LoginAsync(client.Session.AuthenticationToken);
                 if (!String.IsNullOrEmpty(user.UserId))
                 {
                     dynamic meResult = operationResult.Result;
                     if (meResult.first_name != null && meResult.last_name != null)
                         //initiliazed user LiveUserInfo properties
                         SetUserDetails(user.UserId, meResult.name, meResult.first_name, meResult.last_name, pic.Result.location);
                     else
                         infoTextBlock.Text = "Welcome, Guest!";
                 }
             }
             catch (LiveConnectException exception)
             {
                 this.infoTextBlock.Text = "Error calling API: " +
                     exception.Message;
             }
         }
     }
 }
开发者ID:nchejara,项目名称:AzureMobileServiceApps,代码行数:34,代码来源:MainPage.xaml.cs

示例2: UploadFile

        private void UploadFile (string name)
            {
            try
                {
                using (var storage = IsolatedStorageFile.GetUserStoreForApplication ())
                    {
                    var fileStream = storage.OpenFile (name + ".wav", FileMode.Open);
                    var uploadClient = new LiveConnectClient (Utilities.SkyDriveSession);
                    uploadClient.UploadCompleted += UploadClient_UploadCompleted;
                    uploadClient.UploadAsync ("me/skydrive", name + ".wav", fileStream, OverwriteOption.Rename);
                    _progressIndicatror = new ProgressIndicator
                    {
                        IsVisible = true,
                        IsIndeterminate = true,
                        Text = "Uploading file..."
                    };

                    SystemTray.SetProgressIndicator (this, _progressIndicatror);
                    }
                }
            catch (Exception)
                {
                ShowError ();
                NavigationService.GoBack ();
                }
            }
开发者ID:harishasan,项目名称:Circular-Recorder,代码行数:26,代码来源:Upload.xaml.cs

示例3: Button_Click_1

        private async void Button_Click_1(object sender, RoutedEventArgs e)
        {
            var liveIdClient = new LiveAuthClient();
            Task<LiveLoginResult> tskLoginResult = liveIdClient.LoginAsync(new string[] { "wl.signin" });
            tskLoginResult.Wait();

            switch (tskLoginResult.Result.Status)
            {
                case LiveConnectSessionStatus.Connected:

                    try
                    {
                        LiveConnectClient client = new LiveConnectClient(tskLoginResult.Result.Session);
                        LiveOperationResult liveOperationResult = await client.GetAsync("me");

                        dynamic operationResult = liveOperationResult.Result;
                        string name = string.Format("Hello {0} ", operationResult.first_name);
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(string.Format("ERRO, {0}", ex.Message), ex);
                    }

                    break;
                case LiveConnectSessionStatus.NotConnected:
                    int j = 10;
                    break;
                default:
                    int z = 10;
                    break;
            }
        }
开发者ID:aboimpinto,项目名称:GOT.Prolegis,代码行数:32,代码来源:MainPage.xaml.cs

示例4: GetFolderContents

        public async static Task<List<SkyDriveEntity>> GetFolderContents(LiveConnectSession session, string folderId)
        {
            try
            {
                LiveConnectClient client = new LiveConnectClient(session);
                LiveOperationResult result = await client.GetAsync(folderId + "/files");

                //clear entries in data
                data.Clear();

                List<object> container = (List<object>)result.Result["data"];
                foreach (var item in container)
                {
                    SkyDriveEntity entity = new SkyDriveEntity();

                    IDictionary<string, object> dictItem = (IDictionary<string, object>)item;
                    string type = dictItem["type"].ToString();
                    entity.IsFolder = type == "folder" || type == "album" ? true : false;
                    entity.ID = dictItem["id"].ToString();
                    entity.Name = dictItem["name"].ToString();
                    data.Add(entity);
                }
                return null;
            }
            catch
            {
                return null;
            }
        }
开发者ID:Hitchhikrr,项目名称:SkyStream,代码行数:29,代码来源:MainPage.xaml.cs

示例5: loginButton_Click

        private  async void loginButton_Click(object sender, RoutedEventArgs e)//登录
        {
            try
            {
                msgText.Text = "亲:正在登录";
                var authClient = new LiveAuthClient();

                LiveLoginResult result = await authClient.LoginAsync(new string[] { "wl.signin", "wl.skydrive" });

                if (result.Status == LiveConnectSessionStatus.Connected)
                {

                    var connectClient = new LiveConnectClient(result.Session);
                    var meResult = await connectClient.GetAsync("me");
                    msgText.Text = "亲爱的:" + meResult.Result["name"].ToString() + "  您已成功登录OneDrive!";
                }
                updateButton.Visibility = Visibility.Visible;
                uploadButton.Visibility = Visibility.Visible;
                downButton.Visibility = Visibility.Visible;


            }
            catch (LiveAuthException ex)
            {
                msgText.Text = ex.Message;
            }
            catch (LiveConnectException ex)
            {
                msgText.Text = ex.Message;
            }
        }
开发者ID:x01673,项目名称:BCMeng_Project,代码行数:31,代码来源:OneDrive.xaml.cs

示例6: GetUserLogged

        private async Task<dynamic> GetUserLogged() 
        {
            var liveIdClient = new LiveAuthClient();
            Task<LiveLoginResult> tskLoginResult = liveIdClient.LoginAsync(new string[] { "wl.signin" });
            tskLoginResult.Wait();

            switch (tskLoginResult.Result.Status)
            {
                case LiveConnectSessionStatus.Connected:
                    try
                    {
                        LiveConnectClient client = new LiveConnectClient(tskLoginResult.Result.Session);
                        LiveOperationResult liveOperationResult = await client.GetAsync("me");

                        dynamic operationResult = liveOperationResult.Result;
                        return operationResult;
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(string.Format("ERRO, {0}", ex.Message), ex);
                    }
                case LiveConnectSessionStatus.NotConnected:
                    break;
            }

            return null;
        }
开发者ID:aboimpinto,项目名称:GOT.Prolegis,代码行数:27,代码来源:ProlegisViewModelBase.cs

示例7: DownloadPictures

        /// <summary>
        /// DownloadPictures downs picutre link from sky dirve
        /// </summary>
        /// <param name="albumItem"></param>
        private async void DownloadPictures(SkydriveAlbum albumItem)
        {
            LiveConnectClient folderListClient = new LiveConnectClient(App.Session);
            LiveOperationResult result = await folderListClient.GetAsync(albumItem.ID + "/files");
            FolderListClient_GetCompleted(result, albumItem);

        }
开发者ID:masiboo,项目名称:SkyPhoto_WP8,代码行数:11,代码来源:AlbumDetailPage.xaml.cs

示例8: liveSignIn_SessionChanged

 private async void liveSignIn_SessionChanged(object sender, Microsoft.Live.Controls.LiveConnectSessionChangedEventArgs e)
 {
     if (e.Status == LiveConnectSessionStatus.Connected)
     {
         liveClient = new LiveConnectClient(e.Session);
         LiveOperationResult operationResult = await liveClient.GetAsync("me");
         try
         {
             dynamic meResult = operationResult.Result;
             if (meResult.first_name != null && meResult.last_name != null)
             {
                 infoTextBlock.Text = "Hello " + meResult.first_name + " " + meResult.last_name + "!";
             }
             else
             {
                 infoTextBlock.Text = "Hello, signed-in user!";
             }
         }
         catch (LiveConnectException exception)
         {
             this.infoTextBlock.Text = "Error calling API: " + exception.Message;
         }
     }
     else
     {
         infoTextBlock.Text = "Not signed in.";
     }
 }
开发者ID:RRosier,项目名称:GlucoseManager,代码行数:28,代码来源:ConnectLivePage.xaml.cs

示例9: OnNavigatedTo

        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            if (this.NavigationContext.QueryString.ContainsKey("path"))
            {
                this.folderPath = NavigationContext.QueryString["path"];
            }
            if (this.NavigationContext.QueryString.ContainsKey("id"))
            {
                this.fileID = NavigationContext.QueryString["id"];
            }
            if (this.NavigationContext.QueryString.ContainsKey("filename"))
            {
                this.filename = this.NavigationContext.QueryString["filename"];
                this.filenameInput.Text = this.filename;
            }

            if (this.fileID != null)
            { // try to get file contents

                this.progressIndicator = new ProgressIndicator();
                this.progressIndicator.IsIndeterminate = true;
                this.progressIndicator.IsVisible = true;
                this.progressIndicator.Text = "Looking for rain...";
                SystemTray.SetProgressIndicator(this, this.progressIndicator);

                LiveConnectClient client = new LiveConnectClient(App.Current.LiveSession);
                client.DownloadCompleted += new EventHandler<LiveDownloadCompletedEventArgs>(OnFileDownloadComplete);
                client.DownloadAsync(this.fileID+"/content");
            }
            else
            {
                this.contentInput.IsEnabled = true;
                this.filenameInput.Focus(); // doesn't work as it is here, maybe because page isn't actually loaded yet?
            }
        }
开发者ID:dwhitney7,项目名称:SkyNote,代码行数:35,代码来源:EditFile.xaml.cs

示例10: TestLiveSDKLogin

        /// <summary>
        /// Tests logging into MobileService with Live SDK token. App needs to be assosciated with a WindowsStoreApp
        /// </summary>
        private async Task TestLiveSDKLogin()
        {
            try
            {
                LiveAuthClient liveAuthClient = new LiveAuthClient(GetClient().MobileAppUri.ToString());
                LiveLoginResult result = await liveAuthClient.InitializeAsync(new string[] { "wl.basic", "wl.offline_access", "wl.signin" });
                if (result.Status != LiveConnectSessionStatus.Connected)
                {
                    result = await liveAuthClient.LoginAsync(new string[] { "wl.basic", "wl.offline_access", "wl.signin" });
                }
                if (result.Status == LiveConnectSessionStatus.Connected)
                {
                    LiveConnectSession session = result.Session;
                    LiveConnectClient client = new LiveConnectClient(result.Session);
                    LiveOperationResult meResult = await client.GetAsync("me");
                    MobileServiceUser loginResult = await GetClient().LoginWithMicrosoftAccountAsync(result.Session.AuthenticationToken);

                    Log(string.Format("{0} is now logged into MobileService with userId - {1}", meResult.Result["first_name"], loginResult.UserId));
                }
            }
            catch (Exception exception)
            {
                Log(string.Format("ExceptionType: {0} Message: {1} StackTrace: {2}",
                                                exception.GetType().ToString(),
                                                exception.Message,
                                                exception.StackTrace));
                Assert.Fail("Log in with Live SDK failed");
            }
        }
开发者ID:jwallra,项目名称:azure-mobile-apps-net-client,代码行数:32,代码来源:ClientSDKLoginTests.cs

示例11: ensureConnection

 private async Task<LiveConnectClient> ensureConnection()
 {
     if (connection != null)
     {
         return connection;
     }
     // Initialize access to the Live Connect SDK.
     LiveAuthClient LCAuth = new LiveAuthClient("https://chivalry.azure-mobile.net/");
     LiveLoginResult LCLoginResult = await LCAuth.InitializeAsync();
     // Sign in to the user's Microsoft account with the required scope.
     //    
     //  This call will display the Microsoft account sign-in screen if the user 
     //  is not already signed in to their Microsoft account through Windows 8.
     // 
     //  This call will also display the consent dialog, if the user has 
     //  has not already given consent to this app to access the data described 
     //  by the scope.
     // 
     LiveLoginResult loginResult = await LCAuth.LoginAsync(new string[] { "wl.basic", "wl.emails" });
     if (loginResult.Status == LiveConnectSessionStatus.Connected)
     {
         // Create a client session to get the profile data.
         connection = new LiveConnectClient(LCAuth.Session);
         mobileServiceUser = await App.MobileService.LoginAsync(loginResult.Session.AuthenticationToken);
         return connection;
     }
     if (LoginFailed != null)
     {
         LoginFailed(this, null);
     }
     return null;
 }
开发者ID:NickHeiner,项目名称:chivalry,代码行数:32,代码来源:Auth.cs

示例12: Authenticate

        public async Task Authenticate(LiveConnectSessionChangedEventArgs e)
        {
            if (e.Status == LiveConnectSessionStatus.Connected)
            {
                CurrentLoginStatus = "Connected to Microsoft Services";
                liveConnectClient = new LiveConnectClient(e.Session);
                microsoftAccountLoggedInUser = await liveConnectClient.GetAsync("me");

                CurrentLoginStatus = "Getting Microsoft Account Details";
                mobileServiceLoggedInUser =
                    await App.MobileService.LoginWithMicrosoftAccountAsync(e.Session.AuthenticationToken);

                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;
                CurrentLoginStatus = string.Empty;
                // this will then flip the bit that shows the different UI for logged in

                await UpdateUserOnRemoteService(); // and update on the remote service
                await UpdateLeaderBoard(); // do first pass on leaderboard update
            }
            else
            {
                CurrentLoginStatus = "Y U NO LOGIN?";
                CurrentlyLoggedIn = false;
            }

        }
开发者ID:nickhodge,项目名称:HeadsTails,代码行数:31,代码来源:HeadsTailsUserDetailsModel.cs

示例13: InitializePage

        private async void InitializePage()
        {
            try
            {
                this.authClient = new LiveAuthClient();
                LiveLoginResult loginResult = await this.authClient.InitializeAsync(scopes);
                if (loginResult.Status == LiveConnectSessionStatus.Connected)
                {
                    if (this.authClient.CanLogout)
                    {
                        this.btnLogin.Content = "Sign Out";
                    }
                    else
                    {
                        this.btnLogin.Visibility = Visibility.Collapsed;
                    }

                    this.liveClient = new LiveConnectClient(loginResult.Session);
                    this.GetMe();
                }
            }
            catch (LiveAuthException authExp)
            {
                this.tbResponse.Text = authExp.ToString();
            }
        }
开发者ID:harishdotnarayanan,项目名称:LiveSDK-for-Windows,代码行数:26,代码来源:MainPage.xaml.cs

示例14: OnSessionChanged

        private void OnSessionChanged(object sender, Microsoft.Live.Controls.LiveConnectSessionChangedEventArgs e)
        {
            if (e.Error == null)
            {
                if (e.Status == LiveConnectSessionStatus.Connected)
                {

                    this.liveClient = new LiveConnectClient(e.Session);

                    this.GetMe();

                    /*var client = new LiveConnectClient(e.Session);
                    client.GetCompleted += (o, args) =>
                    {
                        if (args.Error == null)
                        {
                            MessageBox.Show(Convert.ToString(args.Result["name"]));
                        }
                    };
                    client.GetAsync("me"); */

                }
                else
                {
                    this.liveClient = null; 

                }
            }

        }
开发者ID:griffinfujioka,项目名称:Wish-List,代码行数:30,代码来源:MainPage.xaml.cs

示例15: clientDataFetch_GetCompleted

 void clientDataFetch_GetCompleted(object sender, LiveOperationCompletedEventArgs e)
 {
     if (e.Error == null)
     {
         List<object> data = (List<object>)e.Result["data"];
         string file_id = "";
         foreach (IDictionary<string, object> content in data)
         {
             if ((string)content["name"] == "BillDB.sdf")
                 file_id = (string)content["id"];
         }
         if (file_id == "")
             MessageBox.Show("No database file found.");
         else
         {
             MessageBox.Show("DB id: " + file_id + ";");
             try
             {
                 LiveConnectClient liveClient = new LiveConnectClient(session);
                 liveClient.GetCompleted += new EventHandler<LiveOperationCompletedEventArgs>(shareLink_completed);
                 liveClient.GetAsync(file_id + "/shared_edit_link");
             }
             catch (LiveConnectException exception)
             {
                 MessageBox.Show("Error getting shared edit link: " + exception.Message);
             }
         }
     }
 }
开发者ID:UWbadgers16,项目名称:BillSync,代码行数:29,代码来源:SkyDrive.xaml.cs


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