aboutsummaryrefslogtreecommitdiff
path: root/Aggregator/Parser/Download.cs
blob: eb46dd0b80ea01891734be20e0d0072ce1ff73ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using System.Net;
using System.Threading.Tasks;

namespace Parser {
    public static class Download {
        /// <summary>
        /// Download source from a given site synchronously
        /// </summary>
        /// <param name="site">Site to download from</param>
        /// <returns></returns>
        public static string DownloadXMLSync(string site) {
            using (var client = new WebClient()) {
                return client.DownloadString(site);
            }
        }

        /// <summary>
        /// Download source from a given site asynchronously
        /// </summary>
        /// <param name="site">Site to download from</param>
        /// <returns></returns>
        public static Task<string> DownloadXML(string site) {
            using (var client = new WebClient()) {
                /* TODO: Find some way to circumvent creating a new WebClient every download
                 *2019-02-03 23:43*/
                return client.DownloadStringTaskAsync(site);
            }
        }
    }
}