private async Task<IICalendarCollection> LoadFromUriOrNull(HttpClient httpClient, Uri uri)
{
using (var response = await httpClient.GetAsync(uri))
{
try
{
response.EnsureSuccessStatusCode();
}
catch (Exception)
{
s_logger.ErrorFormat("Can't access timezone data from '{0}'", uri);
return null;
}
try
{
var result = await response.Content.ReadAsStringAsync();
using (var reader = new StringReader(result))
{
var collection = iCalendar.LoadFromStream(reader);
return collection;
}
}
catch (Exception)
{
s_logger.ErrorFormat("Can't parse timezone data from '{0}'", uri);
return null;
}
}
}
}