本文整理汇总了C#中Account.Serialize方法的典型用法代码示例。如果您正苦于以下问题:C# Account.Serialize方法的具体用法?C# Account.Serialize怎么用?C# Account.Serialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Account
的用法示例。
在下文中一共展示了Account.Serialize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Save
public override void Save (Account account, string serviceId)
{
var statusCode = SecStatusCode.Success;
var serializedAccount = account.Serialize ();
var data = NSData.FromString (serializedAccount, NSStringEncoding.UTF8);
//
// Remove any existing record
//
var existing = FindAccount (account.Username, serviceId);
if (existing != null) {
var query = new SecRecord (SecKind.GenericPassword);
query.Service = serviceId;
query.Account = account.Username;
statusCode = SecKeyChain.Remove (query);
if (statusCode != SecStatusCode.Success) {
throw new Exception ("Could not save account to KeyChain: " + statusCode);
}
}
//
// Add this record
//
var record = new SecRecord (SecKind.GenericPassword);
record.Service = serviceId;
record.Account = account.Username;
record.Generic = data;
record.Accessible = SecAccessible.WhenUnlocked;
statusCode = SecKeyChain.Add (record);
if (statusCode != SecStatusCode.Success) {
throw new Exception ("Could not save account to KeyChain: " + statusCode);
}
}
示例2: SecretAccount
public SecretAccount (Account account)
{
bytes = System.Text.Encoding.UTF8.GetBytes (account.Serialize ());
}
示例3: Login
public async Task<IUser> Login(enSocialNetwork socialNetwork)
{
IUser user = null;
try
{
TaskCompletionSource<int> ts = new TaskCompletionSource<int>();
var auth = new OAuth2Authenticator(
clientId: "5042701",
scope: "offline,messages,friends",
authorizeUrl: new Uri("https://oauth.vk.com/authorize"),
redirectUrl: new Uri("https://oauth.vk.com/blank.html"));
auth.AllowCancel = true;
auth.Completed += (s, ee) =>
{
if (!ee.IsAuthenticated)
{
ts.SetResult(0);
return;
}
var request = new OAuth2Request("GET", new Uri("https://api.vk.com/method/users.get"), null, ee.Account);
request.GetResponseAsync().ContinueWith(t =>
{
if (t.IsCompleted)
{
Token = ee.Account.Properties["access_token"].ToString();
string account = ee.Account.Serialize();
Account = ee.Account;
//AccountStore.Create(Forms.Context).Save(ee.Account, "Vk");
var response = t.Result.GetResponseText();
var users = JsonConvert.DeserializeObject<XamarinSocialApp.Droid.Data.VkData.VkUsers>(response);
string uid = users.response[0].uid;
string firstName = users.response[0].first_name;
string lastName = users.response[0].last_name;
user = new User()
{
FirstName = firstName,
LastName = lastName,
Uid = uid,
SerializeInfo = Account.Serialize(),
SocialNetwork = enSocialNetwork.VK
};
ts.SetResult(0);
}
else
{
ts.SetResult(0);
return;
}
}, UIScheduler);
};
var intent = auth.GetUI(Forms.Context);
Forms.Context.StartActivity(intent);
await ts.Task;
}
catch (Exception ex)
{
}
return user;
}