internal string RetryWithTokenUpdate(M2MgoCloudAgentConfiguration config, Func <string> func)
 {
     if (_token == null)
     {
         _token = UpdateAccessToken(config);
     }
     try {
         return(func());
     }
     catch (WebException) {
         _token = UpdateAccessToken(config);
         try
         {
             return(func());
         }
         catch (WebException e)
         {
             if (e.Response != null && e.Response is HttpWebResponse)
             {
                 if (((HttpWebResponse)e.Response).StatusCode == HttpStatusCode.NotFound)
                 {
                     return(string.Empty);
                 }
             }
             throw;
         }
     }
 }
Esempio n. 2
0
 internal string RetryWithTokenUpdate(M2MgoCloudAgentConfiguration config, Func <string> func)
 {
     if (_token == null)
     {
         _token = UpdateAccessToken(config);
     }
     try {
         return(func());
     }
     catch (WebException) {
         _token = UpdateAccessToken(config);
         try
         {
             return(func());
         }
         catch (WebException e)
         {
             var resp = e.Response as HttpWebResponse;
             if (resp != null)
             {
                 if (resp.StatusCode == HttpStatusCode.NotFound)
                 {
                     return(string.Empty);
                 }
                 throw new Exception(WebApiRequestExecutor.ReadDataFrom(resp), e);
             }
             throw;
         }
     }
 }