using System; using System.Collections.Generic; using System.Net.Http; using System.Threading.Tasks; namespace IF.Lastfm.Core.Api.Commands { public abstract class LastAsyncCommandBase : IAsyncCommand { public string Method { get; protected set; } public Uri Url { get; protected set; } public IAuth Auth { get; protected set; } public int Page { get; set; } public int Count { get; set; } protected Dictionary Parameters { get; set; } protected LastAsyncCommandBase() { Parameters = new Dictionary(); } public abstract void SetParameters(); protected abstract Uri BuildRequestUrl(); public abstract Task ExecuteAsync(); public abstract Task HandleResponse(HttpResponseMessage response); protected void AddPagingParameters() { Parameters.Add("page", Page.ToString()); Parameters.Add("limit", Count.ToString()); } /// /// Annoying workaround for Windows Phone's caching... /// see http://stackoverflow.com/questions/6334788/windows-phone-7-webrequest-caching /// protected void DisableCaching() { Parameters.Add("disablecachetoken", DateTime.UtcNow.Ticks.ToString()); } } }