Ejemplo n.º 1
0
 /// <summary>
 /// Executes the download list.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="redmineManager">The redmine manager.</param>
 /// <param name="address">The address.</param>
 /// <param name="methodName">Name of the method.</param>
 /// <param name="parameters">The parameters.</param>
 /// <returns></returns>
 public static PaginatedObjects <T> ExecuteDownloadList <T>(RedmineManager redmineManager, string address,
                                                            string methodName,
                                                            NameValueCollection parameters = null) where T : class, new()
 {
     using (var wc = redmineManager.CreateWebClient(parameters))
     {
         try
         {
             var response = wc.DownloadString(address);
             return(RedmineSerializer.DeserializeList <T>(response, redmineManager.MimeFormat));
         }
         catch (WebException webException)
         {
             webException.HandleWebException(methodName, redmineManager.MimeFormat);
         }
         return(null);
     }
 }
        /// <summary>
        /// Executes the download list.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="redmineManager">The redmine manager.</param>
        /// <param name="address">The address.</param>
        /// <param name="methodName">Name of the method.</param>
        /// <param name="parameters">The parameters.</param>
        /// <returns></returns>
        public static async Task <List <T> > ExecuteDownloadList <T>(RedmineManager redmineManager, string address,
                                                                     string methodName,
                                                                     NameValueCollection parameters = null) where T : class, new()
        {
            using (var wc = redmineManager.CreateWebClient(parameters))
            {
                try
                {
                    var response = await wc.DownloadStringTaskAsync(address).ConfigureAwait(false);

                    var result = RedmineSerializer.DeserializeList <T>(response, redmineManager.MimeFormat);
                    if (result != null)
                    {
                        return(result.Objects);
                    }
                }
                catch (WebException webException)
                {
                    webException.HandleWebException(methodName, redmineManager.MimeFormat);
                }
                return(null);
            }
        }