public object Invoke(string method, IArgMaker argMaker, ICodeGetter codeGetter)
        {
            int code = 0;

            for (int i = 0; i < this.maxTries; i++)
            {
                try
                {
                    var login = this.loginMan.Login();
                    var json  = this.transport.Invoke(method, argMaker.GetArgs(login.Token));
                    code = codeGetter.GetCode(json);
                    if (code == AgileCode.ExpiredToken)
                    {
                        throw new LoginException(string.Format("Received {0}", code));
                    }
                    else if (code == AgileCode.Success)
                    {
                        return(json);
                    }
                    throw new ApiException(code, HttpCode.Ok, "Received non-zero Agile Status");
                }
                catch (LoginException)
                {
                    code = AgileCode.ExpiredToken;
                    this.loginMan.ClearLogin();
                    continue;
                }
            }
            throw new ApiException(code, HttpCode.Ok, string.Format("Failed after {0} tries", this.maxTries));
        }
 /// <summary>
 /// Executes an arbitrary JSON-RPC method
 /// </summary>
 /// <remarks>if the codeGetter returns a non-zero code, the method will be retried</remarks>
 /// <param name="method">method to be executed</param>
 /// <param name="codeGetter">an implementation  of ICodeGetter capable of parsing return codes (e.g. DictCodeGetter or CodeGetter) </param>
 /// <param name="args">arguments to be passed into the method</param>
 /// <returns>JSON-RPC result</returns>
 public object ExecRawJson(string method, ICodeGetter codeGetter, params object[] args)
 {
     try
     {
         var argMaker = new AutoTokenArgMaker(args);
         return(this.rpcRetry.Invoke(method, argMaker, codeGetter));
     }
     catch (ApiException)
     {
         throw;
     }
     catch (Exception ex)
     {
         throw new UnknownApiException(string.Format("Failed sending {0} {1}", method, args), ex);
     }
 }