aboutsummaryrefslogtreecommitdiff
path: root/Aggregator/Parser/Download.cs
blob: 158806f936261c37bc2c8fc6bb6434f056cb7a7c (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 Aggregator {
    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);
            }
        }
    }
}