Esempio n. 1
0
        public static async Task <T> GetPaginatedList <T>(T page, string filter = "") where T : PaginatedList
        {
            try
            {
                Type       type = typeof(T);
                RedmineApi api  = type.GetTypeInfo().GetCustomAttribute <RedmineApi>();

                WebRequest  wr       = RedmineClient.Instance.CreatePaginatedRequest(api.Path + ".xml", page, filter);
                WebResponse response = await wr.GetResponseAsync();

                XmlSerializer xml = new XmlSerializer(type);

                return((T)xml.Deserialize(response.GetResponseStream()));
            }
            catch (Exception e)
            {
                handleExceptions(e);
                return(default(T));
            }
        }
Esempio n. 2
0
        public static async Task <T> GetSingle <T>(int id)
        {
            try
            {
                Type       type = typeof(T);
                RedmineApi api  = type.GetTypeInfo().GetCustomAttribute <RedmineApi>();

                WebRequest  wr       = RedmineClient.Instance.CreateRequest(api.Path + $"/{id}.xml");
                WebResponse response = await wr.GetResponseAsync();

                XmlSerializer xml = new XmlSerializer(type);

                return((T)xml.Deserialize(response.GetResponseStream()));
            }
            catch (Exception e)
            {
                handleExceptions(e);
                return(default(T));
            }
        }