コード例 #1
0
ファイル: AVQuery.cs プロジェクト: longyunzhou/NFC
 /// <summary>
 /// Counts the number of objects that match this query.
 /// </summary>
 /// <param name="cancellationToken">The cancellation token.</param>
 /// <returns>The number of objects that match this query.</returns>
 public override Task <int> CountAsync(CancellationToken cancellationToken)
 {
     return(AVUser.GetCurrentUserAsync().OnSuccess(t =>
     {
         return QueryController.CountAsync <T>(this, t.Result, cancellationToken);
     }).Unwrap());
 }
コード例 #2
0
ファイル: AVCloud.cs プロジェクト: longyunzhou/NFC
 public static Task <RealtimeSignature> RequestRealtimeSignatureAsync(CancellationToken cancellationToken = default(CancellationToken))
 {
     return(AVUser.GetCurrentUserAsync(cancellationToken).OnSuccess(t =>
     {
         return RequestRealtimeSignatureAsync(t.Result, cancellationToken);
     }).Unwrap());
 }
コード例 #3
0
ファイル: AVQuery.cs プロジェクト: longyunzhou/NFC
 /// <summary>
 /// Retrieves at most one AVObject that satisfies this query.
 /// </summary>
 /// <param name="cancellationToken">The cancellation token.</param>
 /// <returns>A single AVObject that satisfies this query, or else null.</returns>
 public override Task <T> FirstOrDefaultAsync(CancellationToken cancellationToken)
 {
     return(AVUser.GetCurrentUserAsync().OnSuccess(t =>
     {
         return QueryController.FirstAsync <T>(this, t.Result, cancellationToken);
     }).Unwrap().OnSuccess(t =>
     {
         IObjectState state = t.Result;
         return state == null ? default(T) : AVObject.FromState <T>(state, ClassName);
     }));
 }
コード例 #4
0
ファイル: AVQuery.cs プロジェクト: longyunzhou/NFC
 /// <summary>
 /// Retrieves a list of AVObjects that satisfy this query from LeanCloud.
 /// </summary>
 /// <param name="cancellationToken">The cancellation token.</param>
 /// <returns>The list of AVObjects that match this query.</returns>
 public override Task <IEnumerable <T> > FindAsync(CancellationToken cancellationToken)
 {
     return(AVUser.GetCurrentUserAsync().OnSuccess(t =>
     {
         return QueryController.FindAsync <T>(this, t.Result, cancellationToken);
     }).Unwrap().OnSuccess(t =>
     {
         IEnumerable <IObjectState> states = t.Result;
         return (from state in states
                 select AVObject.FromState <T>(state, ClassName));
     }));
 }
コード例 #5
0
        /// <summary>
        /// Gets the current <see cref="AVSession"/> object related to the current user.
        /// </summary>
        /// <param name="cancellationToken">The cancellation token</param>
        public static Task <AVSession> GetCurrentSessionAsync(CancellationToken cancellationToken)
        {
            return(AVUser.GetCurrentUserAsync().OnSuccess(t1 => {
                AVUser user = t1.Result;
                if (user == null)
                {
                    return Task <AVSession> .FromResult((AVSession)null);
                }

                string sessionToken = user.SessionToken;
                if (sessionToken == null)
                {
                    return Task <AVSession> .FromResult((AVSession)null);
                }

                return SessionController.GetSessionAsync(sessionToken, cancellationToken).OnSuccess(t => {
                    AVSession session = (AVSession)AVObject.CreateWithoutData <AVSession>(null);
                    session.HandleFetchResult(t.Result);
                    return session;
                });
            }).Unwrap());
        }
コード例 #6
0
ファイル: AVSession.cs プロジェクト: longyunzhou/NFC
        /// <summary>
        /// Gets the current <see cref="AVSession"/> object related to the current user.
        /// </summary>
        /// <param name="cancellationToken">The cancellation token</param>
        public static Task <AVSession> GetCurrentSessionAsync(CancellationToken cancellationToken)
        {
            return(AVUser.GetCurrentUserAsync().OnSuccess(t1 =>
            {
                AVUser user = t1.Result;
                if (user == null)
                {
                    return Task <AVSession> .FromResult((AVSession)null);
                }

                string sessionToken = user.SessionToken;
                if (sessionToken == null)
                {
                    return Task <AVSession> .FromResult((AVSession)null);
                }

                return SessionController.GetSessionAsync(sessionToken, cancellationToken).OnSuccess(t =>
                {
                    AVSession session = AVObject.FromState <AVSession>(t.Result, "_Session");
                    return session;
                });
            }).Unwrap());
        }