コード例 #1
0
        public async Task <T> RequestAsync <T>(RestRequest req, int timeout = 0)
        {
            var res = await _restProtocol.RequestDataAsync(req, timeout);

            return(res is JToken
                ? (res as JToken).ToObject <T>()
                : Cast <T>(res));
        }
コード例 #2
0
        public async Task <AuthInfo <TUser, TToken> > Authenticate(TToken token)
        {
            try
            {
                _authInfo = await _restProtocol.RequestDataAsync(new AuthRequest { method = "authenticate", data = token });

                if (_authInfo != null)
                {
                    SetIsAuthenticate(true);
                    return(_authInfo);
                }
                else
                {
                    throw new Exception("no auth info");
                }
            }
            catch (Exception ex)
            {
                _authInfo = null;
                SetIsAuthenticate(false);
                throw ex;
            }
        }