Exemplo n.º 1
0
        public static AuthToken Parse(string text, bool isRgx = false)
        {
            AuthToken token = null;

            if (isRgx)
            {
                var matchAccessToken  = rgxAccessToken.Match(text);
                var matchRefreshToken = rgxRefreshToken.Match(text);
                var matchTokenType    = rgxTokenType.Match(text);
                var matchExpiresIn    = rgxExpiresIn.Match(text);
                if (matchAccessToken.Success &&
                    matchRefreshToken.Success)
                {
                    token = new AuthToken();
                    token.access_token  = matchAccessToken.Groups[1].Value;
                    token.refresh_token = matchRefreshToken.Groups[1].Value;
                    token.token_type    = matchTokenType.Groups[1].Value;
                    token.expires_in    = Convert.ToInt32(matchExpiresIn.Groups[1].Value);
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                token = SerializeExtension.JsonDeserlialize <AuthToken>(text);
            }
            token.ExpiresIn = DateTime.Now.AddSeconds(token.expires_in);
            return(token);
        }
Exemplo n.º 2
0
        public static AuthToken Parse(string text)
        {
            var token = SerializeExtension.JsonDeserlialize <AuthToken>(text);

            token.ExpiresIn = DateTime.Now.AddSeconds(token.expires_in);
            return(token);
        }
Exemplo n.º 3
0
 public static ImageFile Parse(string text)
 {
     return(SerializeExtension.JsonDeserlialize <ImageFile>(text));
 }
Exemplo n.º 4
0
 public async Task <User> GetSelf()
 {
     return(await Get("http://api.huaban.com/users/me", o => SerializeExtension.JsonDeserlialize <User>(o)));
 }
Exemplo n.º 5
0
 public async Task <User> GetSelf()
 {
     return(await Get(Client.API_ME, o => SerializeExtension.JsonDeserlialize <User>(o)));
 }