using System;
using System.Net;
using System.Threading.Tasks;
class Program
{
static void Main(string[] args)
{
var s = GetFile("http://u...content-available-to-author-only...p.net/");
Console.WriteLine(s.Result);
}
static Task<string> GetFile(string url)
{
var tcs = new TaskCompletionSource<string>();
var wc = new WebClient();
wc.DownloadStringCompleted += (sender, e) =>
{
if (e.Error != null)
tcs.TrySetException(e.Error);
else if (e.Cancelled)
tcs.TrySetCanceled();
else
tcs.TrySetResult(e.Result);
wc.Dispose();
};
wc.DownloadStringAsync(new Uri(url));
return tcs.Task;
}
}
dXNpbmcgU3lzdGVtOwp1c2luZyBTeXN0ZW0uTmV0Owp1c2luZyBTeXN0ZW0uVGhyZWFkaW5nLlRhc2tzOwoKY2xhc3MgUHJvZ3JhbQp7CiAgICBzdGF0aWMgdm9pZCBNYWluKHN0cmluZ1tdIGFyZ3MpCiAgICB7CiAgICAgICAgdmFyIHMgPSBHZXRGaWxlKCJodHRwOi8vdS4uLmNvbnRlbnQtYXZhaWxhYmxlLXRvLWF1dGhvci1vbmx5Li4ucC5uZXQvIik7CgogICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKHMuUmVzdWx0KTsKICAgIH0KCiAgICBzdGF0aWMgVGFzazxzdHJpbmc+IEdldEZpbGUoc3RyaW5nIHVybCkKICAgIHsKICAgICAgICB2YXIgdGNzID0gbmV3IFRhc2tDb21wbGV0aW9uU291cmNlPHN0cmluZz4oKTsKCiAgICAgICAgdmFyIHdjID0gbmV3IFdlYkNsaWVudCgpOwoKICAgICAgICB3Yy5Eb3dubG9hZFN0cmluZ0NvbXBsZXRlZCArPSAoc2VuZGVyLCBlKSA9PgogICAgICAgIHsKICAgICAgICAgICAgaWYgKGUuRXJyb3IgIT0gbnVsbCkKICAgICAgICAgICAgICAgIHRjcy5UcnlTZXRFeGNlcHRpb24oZS5FcnJvcik7CiAgICAgICAgICAgIGVsc2UgaWYgKGUuQ2FuY2VsbGVkKQogICAgICAgICAgICAgICAgdGNzLlRyeVNldENhbmNlbGVkKCk7CiAgICAgICAgICAgIGVsc2UKICAgICAgICAgICAgICAgIHRjcy5UcnlTZXRSZXN1bHQoZS5SZXN1bHQpOwogICAgICAgICAgICB3Yy5EaXNwb3NlKCk7CiAgICAgICAgfTsKCiAgICAgICAgd2MuRG93bmxvYWRTdHJpbmdBc3luYyhuZXcgVXJpKHVybCkpOwoKICAgICAgICByZXR1cm4gdGNzLlRhc2s7CiAgICB9Cn0=