コード例 #1
0
 /// <summary>
 /// Unsubscribe the current installation from this channel. This is shorthand for:
 ///
 /// <code>
 /// var installation = ParseInstallation.CurrentInstallation;
 /// installation.Remove("channels", channel);
 /// installation.SaveAsync(cancellationToken);
 /// </code>
 /// </summary>
 /// <param name="channel">The channel from which this installation should unsubscribe.</param>
 /// <param name="cancellationToken">CancellationToken to cancel the current operation.</param>
 public static Task UnsubscribeToPushChannelAsync(this IServiceHub serviceHub, string channel, CancellationToken cancellationToken = default) => UnsubscribeToPushChannelsAsync(serviceHub, new List <string> {
     channel
 }, cancellationToken);
 internal static void ClearInMemoryInstallation(this IServiceHub serviceHub) => serviceHub.CurrentInstallationController.ClearFromMemory();
コード例 #3
0
 /// <summary>
 /// Private method, used by platform-specific extensions to report an app-open
 /// to the server.
 /// </summary>
 /// <param name="pushHash">An identifying hash for a given push notification,
 /// passed down from the server.</param>
 /// <returns>An Async Task that can be waited on or ignored.</returns>
 static Task TrackLaunchWithPushHashAsync(this IServiceHub serviceHub, string pushHash = null) => serviceHub.CurrentUserController.GetCurrentSessionTokenAsync(serviceHub).OnSuccess(task => serviceHub.AnalyticsController.TrackAppOpenedAsync(pushHash, task.Result, serviceHub)).Unwrap();
コード例 #4
0
 /// <summary>
 /// Pushes an arbitrary payload to every device subscribed to any of channels. This is shorthand for:
 ///
 /// <code>
 /// var push = new ParsePush();
 /// push.Channels = channels;
 /// push.Data = data;
 /// return push.SendAsync();
 /// </code>
 /// </summary>
 /// <param name="data">A push payload. See the ParsePush.Data property for more information.</param>
 /// <param name="channels">An Installation must be subscribed to any of channels to receive this Push Notification.</param>
 public static Task SendPushDataAsync(this IServiceHub serviceHub, IDictionary <string, object> data, IEnumerable <string> channels) => new ParsePush(serviceHub)
 {
     Channels = channels, Data = data
 }.SendAsync();
コード例 #5
0
 /// <summary>
 /// Logs out the currently logged in user session. This will remove the session from disk, log out of
 /// linked services, and future calls to <see cref="GetCurrentUser()"/> will return <c>null</c>.
 /// </summary>
 /// <remarks>
 /// Typically, you should use <see cref="LogOutAsync()"/>, unless you are managing your own threading.
 /// </remarks>
 public static void LogOut(this IServiceHub serviceHub) => LogOutAsync(serviceHub).Wait(); // TODO (hallucinogen): this will without a doubt fail in Unity. But what else can we do?
コード例 #6
0
 /// <summary>
 /// Tracks this application being launched.
 /// </summary>
 /// <returns>An Async Task that can be waited on or ignored.</returns>
 public static Task TrackLaunchAsync(this IServiceHub serviceHub) => TrackLaunchWithPushHashAsync(serviceHub);
コード例 #7
0
 /// <summary>
 /// Constructs a query. A default query with no further parameters will retrieve
 ///     all Parse.ParseObjects of the provided class.
 /// </summary>
 /// <param name="serviceHub">the service hub to use for this request</param>
 /// <param name="className">The name of the class to retrieve ParseObjects for.</param>
 public ParseQueryLive(IServiceHub serviceHub, string className) : base(serviceHub, className)
 {
     ServiceHub = serviceHub;
     ClassName  = className;
 }
コード例 #8
0
 /// <summary>
 /// Logs in a user with a username and password. On success, this saves the session to disk or to memory so you can retrieve the currently logged in user using <see cref="GetCurrentUser(IServiceHub)"/>.
 /// </summary>
 /// <param name="serviceHub">The <see cref="IServiceHub"/> instance to target when logging in.</param>
 /// <param name="username">The username to log in with.</param>
 /// <param name="password">The password to log in with.</param>
 /// <param name="cancellationToken">The cancellation token.</param>
 /// <returns>The newly logged-in user.</returns>
 public static Task <ParseUser> LogInAsync(this IServiceHub serviceHub, string username, string password, CancellationToken cancellationToken = default) => serviceHub.UserController.LogInAsync(username, password, serviceHub, cancellationToken).OnSuccess(task =>
 {
     ParseUser user = serviceHub.GenerateObjectFromState <ParseUser>(task.Result, "_User");
     return(SaveCurrentUserAsync(serviceHub, user).OnSuccess(_ => user));
 }).Unwrap();
コード例 #9
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 SaveAsync(this ParseFile file, IServiceHub serviceHub, IProgress <IDataTransferLevel> progress, CancellationToken cancellationToken = default) => serviceHub.SaveFileAsync(file, progress, cancellationToken);
コード例 #10
0
 /// <summary>
 /// Constructs a query based upon the ParseObject subclass used as the generic parameter
 //     for the ParseQuery.
 /// </summary>
 /// <param name="serviceHub">the service hub to use for this request</param>
 public ParseQueryLive(IServiceHub serviceHub) : base(serviceHub)
 {
     ServiceHub = serviceHub;
 }
コード例 #11
0
 /// <summary>
 /// Saves the file to the Parse cloud.
 /// </summary>
 /// <param name="cancellationToken">The cancellation token.</param>
 public static Task SaveAsync(this ParseFile file, IServiceHub serviceHub, CancellationToken cancellationToken = default) => serviceHub.SaveFileAsync(file, cancellationToken);
コード例 #12
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);
コード例 #13
0
 public object Encode(IServiceHub serviceHub) => new Dictionary <string, object>
 {
     ["__op"] = "Delete"
 };
コード例 #14
0
        // TODO: Consider renaming SignUpAsync and LogInAsync to SignUpWithAsync and LogInWithAsync, respectively.
        // TODO: Consider returning the created user from the SignUpAsync overload that accepts a username and password.

        /// <summary>
        /// Creates a new <see cref="ParseUser"/>, saves it with the target Parse Server instance, and then authenticates it on the target client.
        /// </summary>
        /// <param name="serviceHub">The <see cref="IServiceHub"/> instance to target when creating the user and authenticating.</param>
        /// <param name="username">The value that should be used for <see cref="ParseUser.Username"/>.</param>
        /// <param name="password">The value that should be used for <see cref="ParseUser.Password"/>.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        public static Task SignUpAsync(this IServiceHub serviceHub, string username, string password, CancellationToken cancellationToken = default) => new ParseUser
        {
            Services = serviceHub, Username = username, Password = password
        }

        .SignUpAsync(cancellationToken);
コード例 #15
0
 public Task SendPushNotificationAsync(IPushState state, IServiceHub serviceHub, CancellationToken cancellationToken = default) => CurrentUserController.GetCurrentSessionTokenAsync(serviceHub, cancellationToken).OnSuccess(sessionTokenTask => CommandRunner.RunCommandAsync(new ParseCommand("push", method: "POST", sessionToken: sessionTokenTask.Result, data: ParsePushEncoder.Instance.Encode(state)), cancellationToken: cancellationToken)).Unwrap();
コード例 #16
0
 /// <summary>
 /// Saves the provided <see cref="ParseUser"/> instance with the target Parse Server instance and then authenticates it on the target client. This method should only be used once <see cref="ParseClient.Publicize"/> has been called and <see cref="ParseClient.Instance"/> is the wanted bind target, or if <see cref="ParseObject.Services"/> has already been set or <see cref="ParseObject.Bind(IServiceHub)"/> has already been called on the <paramref name="user"/>.
 /// </summary>
 /// <param name="serviceHub">The <see cref="IServiceHub"/> instance to target when creating the user and authenticating.</param>
 /// <param name="user">The <see cref="ParseUser"/> instance to save on the target Parse Server instance and authenticate.</param>
 /// <param name="cancellationToken">The cancellation token.</param>
 public static Task SignUpAsync(this IServiceHub serviceHub, ParseUser user, CancellationToken cancellationToken = default)
 {
     user.Bind(serviceHub);
     return(user.SignUpAsync(cancellationToken));
 }
コード例 #17
0
 public static ParseQuery <T> GetQuery <T>(this IServiceHub serviceHub) where T : ParseObject => new ParseQuery <T>(serviceHub);
コード例 #18
0
 /// <summary>
 /// Logs in a user with a username and password. On success, this saves the session to disk so you
 /// can retrieve the currently logged in user using <see cref="GetCurrentUser()"/>.
 /// </summary>
 /// <param name="sessionToken">The session token to authorize with</param>
 /// <param name="cancellationToken">The cancellation token.</param>
 /// <returns>The user if authorization was successful</returns>
 public static Task <ParseUser> BecomeAsync(this IServiceHub serviceHub, string sessionToken, CancellationToken cancellationToken = default) => serviceHub.UserController.GetUserAsync(sessionToken, serviceHub, cancellationToken).OnSuccess(t =>
 {
     ParseUser user = serviceHub.GenerateObjectFromState <ParseUser>(t.Result, "_User");
     return(SaveCurrentUserAsync(serviceHub, user).OnSuccess(_ => user));
 }).Unwrap();
コード例 #19
0
        // ALTERNATE NAME: BuildOrQuery

        /// <summary>
        /// Constructs a query that is the or of the given queries.
        /// </summary>
        /// <typeparam name="T">The type of ParseObject being queried.</typeparam>
        /// <param name="source">An initial query to 'or' with additional queries.</param>
        /// <param name="queries">The list of ParseQueries to 'or' together.</param>
        /// <returns>A query that is the or of the given queries.</returns>
        public static ParseQuery <T> ConstructOrQuery <T>(this IServiceHub serviceHub, ParseQuery <T> source, params ParseQuery <T>[] queries) where T : ParseObject => serviceHub.ConstructOrQuery(queries.Concat(new[] { source }));
コード例 #20
0
        public static void LogOut(this IServiceHub serviceHub) => LogOutAsync(serviceHub).Wait(); // TODO (hallucinogen): this will without a doubt fail in Unity. But what else can we do?

        /// <summary>
        /// Logs out the currently logged in user session. This will remove the session from disk, log out of
        /// linked services, and future calls to <see cref="GetCurrentUser()"/> will return <c>null</c>.
        /// </summary>
        /// <remarks>
        /// This is preferable to using <see cref="LogOut()"/>, unless your code is already running from a
        /// background thread.
        /// </remarks>
        public static Task LogOutAsync(this IServiceHub serviceHub) => LogOutAsync(serviceHub, CancellationToken.None);
コード例 #21
0
        // TODO: Implement IServiceHubMutator in all IServiceHub-implementing classes in Parse.Library and possibly require all implementations to do so as an efficiency improvement over instantiating an OrchestrationServiceHub, only for another one to be possibly instantiated when configurators are specified.

        /// <summary>
        /// Creates a new <see cref="ParseClient"/> and authenticates it as belonging to your application. This class is a hub for interacting with the SDK. The recommended way to use this class on client applications is to instantiate it, then call <see cref="Publicize"/> on it in your application entry point. This allows you to access <see cref="Instance"/>.
        /// </summary>
        /// <param name="applicationID">The Application ID provided in the Parse dashboard.</param>
        /// <param name="serverURI">The server URI provided in the Parse dashboard.</param>
        /// <param name="key">The .NET Key provided in the Parse dashboard.</param>
        /// <param name="serviceHub">A service hub to override internal services and thereby make the Parse SDK operate in a custom manner.</param>
        /// <param name="configurators">A set of <see cref="IServiceHubMutator"/> implementation instances to tweak the behaviour of the SDK.</param>
        public ParseClient(string applicationID, string serverURI, string key, IServiceHub serviceHub = default, params IServiceHubMutator[] configurators) : this(new ServerConnectionData {
            ApplicationID = applicationID, ServerURI = serverURI, Key = key
        }, serviceHub, configurators)
        {
        }
コード例 #22
0
 /// <summary>
 /// Tracks the occurrence of a custom event with additional dimensions.
 /// Parse will store a data point at the time of invocation with the
 /// given event name.
 ///
 /// Dimensions will allow segmentation of the occurrences of this
 /// custom event.
 ///
 /// To track a user signup along with additional metadata, consider the
 /// following:
 /// <code>
 /// IDictionary&lt;string, string&gt; dims = new Dictionary&lt;string, string&gt; {
 ///   { "gender", "m" },
 ///   { "source", "web" },
 ///   { "dayType", "weekend" }
 /// };
 /// ParseAnalytics.TrackEventAsync("signup", dims);
 /// </code>
 ///
 /// There is a default limit of 8 dimensions per event tracked.
 /// </summary>
 /// <param name="name">The name of the custom event to report to ParseClient
 /// as having happened.</param>
 /// <returns>An Async Task that can be waited on or ignored.</returns>
 public static Task TrackAnalyticsEventAsync(this IServiceHub serviceHub, string name) => TrackAnalyticsEventAsync(serviceHub, name, default);
コード例 #23
0
 /// <summary>
 /// Creates a new <see cref="ParseClient"/> and authenticates it as belonging to your application. This class is a hub for interacting with the SDK. The recommended way to use this class on client applications is to instantiate it, then call <see cref="Publicize"/> on it in your application entry point. This allows you to access <see cref="Instance"/>.
 /// </summary>
 /// <param name="configuration">The configuration to initialize Parse with.</param>
 /// <param name="serviceHub">A service hub to override internal services and thereby make the Parse SDK operate in a custom manner.</param>
 /// <param name="configurators">A set of <see cref="IServiceHubMutator"/> implementation instances to tweak the behaviour of the SDK.</param>
 public ParseClient(IServerConnectionData configuration, IServiceHub serviceHub = default, params IServiceHubMutator[] configurators)
 {
     Services = serviceHub is { } ? new OrchestrationServiceHub {
コード例 #24
0
 /// <summary>
 /// Pushes an arbitrary payload to every device subscribed to channel. This is shorthand for:
 ///
 /// <code>
 /// var push = new ParsePush();
 /// push.Channels = new List&lt;string&gt; { channel };
 /// push.Data = data;
 /// return push.SendAsync();
 /// </code>
 /// </summary>
 /// <param name="data">A push payload. See the ParsePush.Data property for more information.</param>
 /// <param name="channel">An Installation must be subscribed to channel to receive this Push Notification.</param>
 public static Task SendPushDataAsync(this IServiceHub serviceHub, IDictionary <string, object> data, string channel) => new ParsePush(serviceHub)
 {
     Channels = new List <string> {
         channel
     }, Data = data
 }.SendAsync();
コード例 #25
0
 /// <summary>
 /// Logs out the currently logged in user session. This will remove the session from disk, log out of
 /// linked services, and future calls to <see cref="GetCurrentUser(IServiceHub)"/> will return <c>null</c>.
 ///
 /// This is preferable to using <see cref="LogOut()"/>, unless your code is already running from a
 /// background thread.
 /// </summary>
 public static Task LogOutAsync(this IServiceHub serviceHub, CancellationToken cancellationToken) => GetCurrentUserAsync(serviceHub).OnSuccess(task =>
コード例 #26
0
 /// <summary>
 /// Pushes an arbitrary payload to every device matching target. This is shorthand for:
 ///
 /// <code>
 /// var push = new ParsePush();
 /// push.Query = query
 /// push.Data = data;
 /// return push.SendAsync();
 /// </code>
 /// </summary>
 /// <param name="data">A push payload. See the ParsePush.Data property for more information.</param>
 /// <param name="query">A query filtering the devices which should receive this Push Notification.</param>
 public static Task SendPushDataAsync(this IServiceHub serviceHub, IDictionary <string, object> data, ParseQuery <ParseInstallation> query) => new ParsePush(serviceHub)
 {
     Query = query, Data = data
 }.SendAsync();
コード例 #27
0
 internal static Task <string> GetCurrentSessionTokenAsync(this IServiceHub serviceHub, CancellationToken cancellationToken = default) => serviceHub.CurrentUserController.GetCurrentSessionTokenAsync(serviceHub, cancellationToken);
コード例 #28
0
 /// <summary>
 /// Unsubscribe the current installation from these channels. This is shorthand for:
 ///
 /// <code>
 /// var installation = ParseInstallation.CurrentInstallation;
 /// installation.RemoveAllFromList("channels", channels);
 /// installation.SaveAsync(cancellationToken);
 /// </code>
 /// </summary>
 /// <param name="channels">The channels from which this installation should unsubscribe.</param>
 /// <param name="cancellationToken">CancellationToken to cancel the current operation.</param>
 public static Task UnsubscribeToPushChannelsAsync(this IServiceHub serviceHub, IEnumerable <string> channels, CancellationToken cancellationToken = default) => serviceHub.PushChannelsController.UnsubscribeAsync(channels, serviceHub, cancellationToken);
 /// <summary>
 /// Constructs a <see cref="ParseQuery{ParseInstallation}"/> for ParseInstallations.
 /// </summary>
 /// <remarks>
 /// Only the following types of queries are allowed for installations:
 ///
 /// <code>
 /// query.GetAsync(objectId)
 /// query.WhereEqualTo(key, value)
 /// query.WhereMatchesKeyInQuery&lt;TOther&gt;(key, keyInQuery, otherQuery)
 /// </code>
 ///
 /// You can add additional query conditions, but one of the above must appear as a top-level <c>AND</c>
 /// clause in the query.
 /// </remarks>
 public static ParseQuery <ParseInstallation> GetInstallationQuery(this IServiceHub serviceHub) => new ParseQuery <ParseInstallation>(serviceHub);