Example #1
0
 private async Task<XDocument> QueryTrackAsync(LastFmMethod method, string artist, string track)
 {
     Dictionary<string, string> query = new Dictionary<string, string>(){
         { "artist", artist }, { "track", track }
     };
     return await QueryAsync(GenerateUrl(method, query));
 }
Example #2
0
 private async Task<XDocument> QueryTrackAsync(LastFmMethod method, string artist, string track)
 {
     var query = new Dictionary<string, object>(){
         { "artist", artist }, { "track", track }, { "limit", ResultLimit }
     };
     return await QueryAsync(GenerateUrl(method, query));
 }
Example #3
0
 private async Task<XDocument> QueryGlobalAsync(LastFmMethod method)
 {
     var query = new Dictionary<string, object>(){
         { "limit", ResultLimit }
     };
     return await QueryAsync(GenerateUrl(method, new Dictionary<string, object>()));
 }
Example #4
0
        private string GetMethodName(LastFmMethod method)
        {
            var attribute = (LastFmMethodNameAttribute)method.GetType()
                .GetMember(method.ToString()).First()
                .GetCustomAttributes(typeof(LastFmMethodNameAttribute), false)
                .First();

            return attribute.Value;
        }
Example #5
0
        private async Task <XDocument> QueryGlobalAsync(LastFmMethod method)
        {
            var query = new Dictionary <string, object>()
            {
                { "limit", ResultLimit }
            };

            return(await QueryAsync(GenerateUrl(method, new Dictionary <string, object>())));
        }
Example #6
0
        private async Task <XDocument> QueryTrackAsync(LastFmMethod method, string artist, string track)
        {
            var query = new Dictionary <string, object>()
            {
                { "artist", artist }, { "track", track }, { "limit", ResultLimit }
            };

            return(await QueryAsync(GenerateUrl(method, query)));
        }
Example #7
0
        private string GetMethodName(LastFmMethod method)
        {
            var attribute = (LastFmMethodNameAttribute)method.GetType()
                            .GetMember(method.ToString()).First()
                            .GetCustomAttributes(typeof(LastFmMethodNameAttribute), false)
                            .First();

            return(attribute.Value);
        }
Example #8
0
 private string GenerateUrl(
     LastFmMethod method, 
     Dictionary<string, string> query)
 {
     StringBuilder uri = new StringBuilder(this.serviceUrl);
     AppendQueryString(uri, "method", GetMethodName(method));
     foreach (var kvp in query)
     {
         AppendQueryString(uri, kvp.Key, kvp.Value);
     }
     return uri.ToString();
 }
Example #9
0
        private string GenerateUrl(
            LastFmMethod method,
            Dictionary <string, object> query)
        {
            StringBuilder uri = new StringBuilder(this.serviceUrl);

            AppendQueryString(uri, "method", GetMethodName(method));
            foreach (var kvp in query)
            {
                AppendQueryString(uri, kvp.Key, kvp.Value.ToString());
            }
            return(uri.ToString());
        }
Example #10
0
 private async Task<XDocument> QueryGlobalAsync(LastFmMethod method)
 {
     return await QueryAsync(GenerateUrl(method, new Dictionary<string, string>()));
 }