Ejemplo n.º 1
0
        // a method to make the function call shorter (and thus more convenient for the programmer)
        private string SendRequest <T>(T data)
        {
            try
            {
                Random rand  = new Random();
                int    nonce = rand.Next(Int32.MinValue, Int32.MaxValue);
                string token = req.createToken(nonce);

                var resp = this.client.SendPostRequest <T>(this.req.getUrl(), this.req.getUser(), token, data, nonce);
                RequestTimer.wait();
                RequestTimer.addRequest();
                return(resp);
            }
            catch
            {
                return(null);
            }
        }
Ejemplo n.º 2
0
 // a method to make the function call shorter (and thus more convenient for the programmer)
 private T2 SendRequest <T1, T2>(T1 data) where T2 : class
 {
     try
     {
         Random rand  = new Random();
         int    nonce = rand.Next(Int32.MinValue, Int32.MaxValue);
         string token = req.createToken(nonce);
         RequestTimer.wait();
         var resp = this.client.SendPostRequest <T1, T2>(this.req.getUrl(), this.req.getUser(), token, data, nonce);
         RequestTimer.addRequest();
         return(resp);
     }
     catch (Exception e)
     {
         // in case of an error, print the error message
         Console.WriteLine(e.Message);
         return(null);
     }
 }