diff options
Diffstat (limited to 'MediaBrowser.Controller/Weather/BaseWeatherProvider.cs')
| -rw-r--r-- | MediaBrowser.Controller/Weather/BaseWeatherProvider.cs | 71 |
1 files changed, 37 insertions, 34 deletions
diff --git a/MediaBrowser.Controller/Weather/BaseWeatherProvider.cs b/MediaBrowser.Controller/Weather/BaseWeatherProvider.cs index c3d436e66..4ae7a3991 100644 --- a/MediaBrowser.Controller/Weather/BaseWeatherProvider.cs +++ b/MediaBrowser.Controller/Weather/BaseWeatherProvider.cs @@ -1,34 +1,37 @@ -using MediaBrowser.Common.Logging;
-using MediaBrowser.Model.Weather;
-using System;
-using System.Net;
-using System.Net.Cache;
-using System.Net.Http;
-using System.Threading.Tasks;
-
-namespace MediaBrowser.Controller.Weather
-{
- public abstract class BaseWeatherProvider : IDisposable
- {
- protected HttpClient HttpClient { get; private set; }
-
- protected BaseWeatherProvider()
- {
- var handler = new WebRequestHandler { };
-
- handler.AutomaticDecompression = DecompressionMethods.Deflate;
- handler.CachePolicy = new RequestCachePolicy(RequestCacheLevel.Revalidate);
-
- HttpClient = new HttpClient(handler);
- }
-
- public virtual void Dispose()
- {
- Logger.LogInfo("Disposing " + GetType().Name);
-
- HttpClient.Dispose();
- }
-
- public abstract Task<WeatherInfo> GetWeatherInfoAsync(string zipCode);
- }
-}
+using MediaBrowser.Model.Weather; +using System; +using System.Threading; +using System.Threading.Tasks; + +namespace MediaBrowser.Controller.Weather +{ + /// <summary> + /// Class BaseWeatherProvider + /// </summary> + public abstract class BaseWeatherProvider : IDisposable + { + /// <summary> + /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. + /// </summary> + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + /// <summary> + /// Releases unmanaged and - optionally - managed resources. + /// </summary> + /// <param name="dispose"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param> + protected virtual void Dispose(bool dispose) + { + } + + /// <summary> + /// Gets the weather info async. + /// </summary> + /// <param name="location">The location.</param> + /// <returns>Task{WeatherInfo}.</returns> + public abstract Task<WeatherInfo> GetWeatherInfoAsync(string location, CancellationToken cancellationToken); + } +} |
