public Task SetAsync(ParseUser user, CancellationToken cancellationToken) { return(taskQueue.Enqueue(toAwait => { return toAwait.ContinueWith(_ => { if (user == null) { ParseClient.ApplicationSettings.Remove("CurrentUser"); } else { // TODO (hallucinogen): we need to use ParseCurrentCoder instead of this janky encoding var data = user.ServerDataToJSONObjectForSerialization(); data["objectId"] = user.ObjectId; if (user.CreatedAt != null) { data["createdAt"] = user.CreatedAt.Value.ToString(ParseClient.DateFormatString); } if (user.UpdatedAt != null) { data["updatedAt"] = user.UpdatedAt.Value.ToString(ParseClient.DateFormatString); } ParseClient.ApplicationSettings["CurrentUser"] = Json.Encode(data); } CurrentUser = user; }); }, cancellationToken)); }
public Task SetAsync(ParseUser user, CancellationToken cancellationToken) { return taskQueue.Enqueue(toAwait => { return toAwait.ContinueWith(_ => { Task saveTask = null; if (user == null) { saveTask = storageController .LoadAsync() .OnSuccess(t => t.Result.RemoveAsync("CurrentUser")) .Unwrap(); } else { // TODO (hallucinogen): we need to use ParseCurrentCoder instead of this janky encoding var data = user.ServerDataToJSONObjectForSerialization(); data["objectId"] = user.ObjectId; if (user.CreatedAt != null) { data["createdAt"] = user.CreatedAt.Value.ToString(ParseClient.DateFormatStrings.First()); } if (user.UpdatedAt != null) { data["updatedAt"] = user.UpdatedAt.Value.ToString(ParseClient.DateFormatStrings.First()); } saveTask = storageController .LoadAsync() .OnSuccess(t => t.Result.AddAsync("CurrentUser", Json.Encode(data))) .Unwrap(); } CurrentUser = user; return saveTask; }).Unwrap(); }, cancellationToken); }
public Task SetAsync(ParseUser user, CancellationToken cancellationToken) { return(taskQueue.Enqueue(toAwait => { return toAwait.ContinueWith(_ => { Task saveTask = null; if (user == null) { saveTask = storageController .LoadAsync() .OnSuccess(t => t.Result.RemoveAsync("CurrentUser")) .Unwrap(); } else { // TODO (hallucinogen): we need to use ParseCurrentCoder instead of this janky encoding var data = user.ServerDataToJSONObjectForSerialization(); data["objectId"] = user.ObjectId; if (user.CreatedAt != null) { data["createdAt"] = user.CreatedAt.Value.ToString(ParseClient.DateFormatStrings.First(), CultureInfo.InvariantCulture); } if (user.UpdatedAt != null) { data["updatedAt"] = user.UpdatedAt.Value.ToString(ParseClient.DateFormatStrings.First(), CultureInfo.InvariantCulture); } saveTask = storageController .LoadAsync() .OnSuccess(t => t.Result.AddAsync("CurrentUser", Json.Encode(data))) .Unwrap(); } CurrentUser = user; return saveTask; }, Parse.ParseClient.DefaultTaskContinuationOptions).Unwrap(); }, cancellationToken)); }
public Task SetAsync(ParseUser user, CancellationToken cancellationToken) { return taskQueue.Enqueue(toAwait => { return toAwait.ContinueWith(_ => { if (user == null) { ParseClient.ApplicationSettings.Remove("CurrentUser"); } else { // TODO (hallucinogen): we need to use ParseCurrentCoder instead of this janky encoding var data = user.ServerDataToJSONObjectForSerialization(); data["objectId"] = user.ObjectId; if (user.CreatedAt != null) { data["createdAt"] = user.CreatedAt.Value.ToString(ParseClient.DateFormatString); } if (user.UpdatedAt != null) { data["updatedAt"] = user.UpdatedAt.Value.ToString(ParseClient.DateFormatString); } ParseClient.ApplicationSettings["CurrentUser"] = Json.Encode(data); } CurrentUser = user; }); }, cancellationToken); }