示例#1
0
 /// <summary>
 /// Retrieves the ParseConfig asynchronously from the server.
 /// </summary>
 /// <param name="cancellationToken">The cancellation token.</param>
 /// <returns>ParseConfig object that was fetched</returns>
 public static Task <ParseConfiguration> GetConfigurationAsync(this IServiceHub serviceHub, CancellationToken cancellationToken = default) => serviceHub.ConfigurationController.FetchConfigAsync(serviceHub.GetCurrentSessionToken(), serviceHub, cancellationToken);
示例#2
0
 /// <summary>
 /// Saves the file to the Parse cloud.
 /// </summary>
 /// <param name="progress">The progress callback.</param>
 /// <param name="cancellationToken">The cancellation token.</param>
 public static Task SaveFileAsync(this IServiceHub serviceHub, ParseFile file, IProgress <IDataTransferLevel> progress, CancellationToken cancellationToken = default) => file.TaskQueue.Enqueue(toAwait => serviceHub.FileController.SaveAsync(file.State, file.DataStream, serviceHub.GetCurrentSessionToken(), progress, cancellationToken), cancellationToken).OnSuccess(task => file.State = task.Result);
示例#3
0
 /// <summary>
 /// Calls a cloud function.
 /// </summary>
 /// <typeparam name="T">The type of data you will receive from the cloud function. This
 /// can be an IDictionary, string, IList, ParseObject, or any other type supported by
 /// ParseObject.</typeparam>
 /// <param name="name">The cloud function to call.</param>
 /// <param name="parameters">The parameters to send to the cloud function. This
 /// dictionary can contain anything that could be passed into a ParseObject except for
 /// ParseObjects themselves.</param>
 /// <param name="cancellationToken">The cancellation token.</param>
 /// <returns>The result of the cloud call.</returns>
 public static Task <T> CallCloudCodeFunctionAsync <T>(this IServiceHub serviceHub, string name, IDictionary <string, object> parameters, CancellationToken cancellationToken) => serviceHub.CloudCodeController.CallFunctionAsync <T>(name, parameters, serviceHub.GetCurrentSessionToken(), serviceHub, cancellationToken);
示例#4
0
        /// <summary>
        /// Deletes each object in the provided list.
        /// </summary>
        /// <param name="objects">The objects to delete.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        public static Task DeleteObjectsAsync <T>(this IServiceHub serviceHub, IEnumerable <T> objects, CancellationToken cancellationToken) where T : ParseObject
        {
            HashSet <ParseObject> unique = new HashSet <ParseObject>(objects.OfType <ParseObject>().ToList(), new IdentityEqualityComparer <ParseObject> {
            });

            return(EnqueueForAll(unique, toAwait => toAwait.OnSuccess(_ => Task.WhenAll(serviceHub.ObjectController.DeleteAllAsync(unique.Select(task => task.State).ToList(), serviceHub.GetCurrentSessionToken(), cancellationToken))).Unwrap().OnSuccess(task =>
            {
                // Dirty all objects in memory.

                foreach (ParseObject obj in unique)
                {
                    obj.IsDirty = true;
                }

                return default(object);
            }), cancellationToken));
        }