Esempio n. 1
0
 async Task <JObject> CoreGetObjectsAsync(IEnumerable <string> keys)
 {
     return((JObject) await CallAsync("get", new Dictionary <string, string> {
         ["keys"] = String.Join(",", keys),
         ["extras"] = String.Join(",", RdioObject.GetExtraKeys())
     }));
 }
Esempio n. 2
0
 public async Task <T> GetObjectAsync <T> (string key) where T : RdioObject
 {
     ;
     foreach (var property in await CoreGetObjectsAsync(new [] { key }))
     {
         return(RdioObject.FromJson(property.Value) as T);
     }
     return(null);
 }
Esempio n. 3
0
        public async Task <IEnumerable <RdioObject> > GetObjectsAsync(IEnumerable <string> keys)
        {
            var objects = new List <RdioObject> ();

            foreach (var property in await CoreGetObjectsAsync(keys))
            {
                objects.Add(RdioObject.FromJson(property.Value));
            }
            return(objects);
        }
Esempio n. 4
0
 public async Task LoadObjectsAsync(RdioObjectStore targetStore, IEnumerable <string> keys,
                                    Action <RdioObject> objectLoaded = null)
 {
     foreach (var property in await CoreGetObjectsAsync(keys))
     {
         var obj = RdioObject.FromJson(property.Value);
         if (obj != null)
         {
             targetStore.Add(obj);
             objectLoaded?.Invoke(obj);
         }
     }
 }
Esempio n. 5
0
        public async Task <User> FindUserAsync(string email = null, string vanityName = null)
        {
            var parameters = new Dictionary <string, string> (1);

            if (email != null)
            {
                parameters.Add("email", email);
            }
            else if (vanityName != null)
            {
                parameters.Add("vanityName", vanityName);
            }

            parameters.Add("extras", String.Join(",", RdioObject.GetExtraKeys <User> ()));

            return(await CallAsync <User> ("findUser", parameters));
        }
Esempio n. 6
0
 public async Task <T> CallAsync <T> (string method, IDictionary <string, string> parameters = null)
     where T : RdioObject
 {
     return(RdioObject.FromJson <T> (await CallAsync(method, parameters)));
 }