本文整理汇总了C#中Microsoft.Live.LiveConnectClient.GetAsync方法的典型用法代码示例。如果您正苦于以下问题:C# LiveConnectClient.GetAsync方法的具体用法?C# LiveConnectClient.GetAsync怎么用?C# LiveConnectClient.GetAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Live.LiveConnectClient
的用法示例。
在下文中一共展示了LiveConnectClient.GetAsync方法的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;
}
}
}
}
示例2: btnSignin_SessionChanged_2
private async void btnSignin_SessionChanged_2(object sender, LiveConnectSessionChangedEventArgs e)
{
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)
{
infoTextBlock.Text = "Welcome, " + meResult.name;
//initiliazed user LiveUserInfo properties
LiveUserInfo.Id = user.UserId;//meResult.id; // user.UserId; //generated by Zumo
LiveUserInfo.Name = meResult.name;
LiveUserInfo.FirstName = meResult.first_name;
LiveUserInfo.LastName = meResult.last_name;
PushNotificationChannel channel = await PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync();
LiveUserInfo.channelUri = channel.Uri;
LiveUserInfo.pic = pic.Result.location;
this.Frame.Navigate(typeof(WhereTheFriend.Welcome));
}
else
{
infoTextBlock.Text = "Welcome, Guest!";
}
}
}
catch (LiveConnectException exception)
{
this.infoTextBlock.Text = "Error calling API: " +
exception.Message;
}
}
}
}
示例3: LoadProfile
public async void LoadProfile(String SkyDriveFolderName = GenericName)
{
LiveOperationResult meResult;
dynamic result;
bool createLiveFolder = false;
try
{
LiveAuthClient authClient = new LiveAuthClient();
LiveLoginResult authResult = await authClient.LoginAsync(new List<String>() { "wl.skydrive_update" });
if (authResult.Status == LiveConnectSessionStatus.Connected)
{
try
{
meClient = new LiveConnectClient(authResult.Session);
meResult = await meClient.GetAsync("me/skydrive/" + SkyDriveFolderName);
result = meResult.Result;
}
catch (LiveConnectException)
{
createLiveFolder = true;
}
if (createLiveFolder == true)
{
try
{
var skyDriveFolderData = new Dictionary<String, Object>();
skyDriveFolderData.Add("name", SkyDriveFolderName);
LiveConnectClient LiveClient = new LiveConnectClient(meClient.Session);
LiveOperationResult operationResult = await LiveClient.PostAsync("me/skydrive/", skyDriveFolderData);
meResult = await meClient.GetAsync("me/skydrive/");
}
catch (LiveConnectException)
{
}
}
}
}
catch (LiveAuthException)
{
}
}
示例4: SignInButtonSessionChanged
private void SignInButtonSessionChanged(object sender, LiveConnectSessionChangedEventArgs e)
{
if (e.Session != null)
{
_session = e.Session;
var client = new LiveConnectClient(_session);
EventHandler<LiveOperationCompletedEventArgs> handler = null;
handler = (s, even) =>
{
client.GetCompleted -= handler;
var resultDict = (Dictionary<string, object>)even.Result;
var items = (List<object>)resultDict["data"];
// Перебираем все объекты в папке, отбиаем только тип folder
foreach (var item in
items.Cast<Dictionary<string, object>>().Where(item => item["type"].ToString() == "folder"))
{
_files.Add(new FileModel() { Name = item["name"].ToString() });
}
lbFileList.ItemsSource = _files;
};
client.GetCompleted += handler;
//Путь к корню вашего skydrive
client.GetAsync("me/skydrive/files");
}
}
示例5: 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);
}
}
}
}
示例6: 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;
}
}
示例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);
}
示例8: Index
public async Task<ActionResult> Index()
{
// récupération du statut de la connection de l'utilisateur
var loginResult = await AuthClient.InitializeWebSessionAsync(this.HttpContext);
// si l'utilisateur est connecté
if (loginResult != null && loginResult.Status == LiveConnectSessionStatus.Connected)
{
// Récupération et affichage des informations de l'utilisateur
var userData = new UserDataModel();
LiveConnectClient client = new LiveConnectClient(this.AuthClient.Session);
LiveOperationResult meResult = await client.GetAsync("me");
if (meResult != null)
{
dynamic meInfo = meResult.Result;
userData.LastName = meInfo.last_name;
userData.FirstName = meInfo.first_name;
}
return View("LoggedIn", userData);
}
else
{
// l'utilisateur n'est pas connecté, génération de l'URL de connection
var options = new Dictionary<string, string>();
options["state"] = REDIRECT_URL;
string loginUrl = this.AuthClient.GetLoginUrl(new string[] { "wl.signin" }, REDIRECT_URL, options);
ViewBag.loginUrl = loginUrl;
return View("LoggedOut");
}
}
示例9: 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;
}
示例10: 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;
}
}
示例11: 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.";
}
}
示例12: 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");
}
}
示例13: 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;
}
}
示例14: 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;
}
}
示例15: Redirect
public async Task<ActionResult> Redirect()
{
var result = await authClient.ExchangeAuthCodeAsync(HttpContext);
if (result.Status == LiveConnectSessionStatus.Connected)
{
var client = new LiveConnectClient(this.authClient.Session);
LiveOperationResult meResult = await client.GetAsync("me");
LiveOperationResult mePicResult = await client.GetAsync("me/picture");
LiveOperationResult calendarResult = await client.GetAsync("me/calendars");
ViewBag.Name = meResult.Result["name"].ToString();
ViewBag.PhotoLocation = mePicResult.Result["location"].ToString();
ViewBag.CalendarJson = calendarResult.RawResult;
}
return View();
}