Beispiel #1
0
 public (IStatusCode, string) Download(IUrl str)
 {
     try
     {
         var json = wc.DownloadString(str.GetUrlContext().UrlStr);
         return(new StatusCodeImplementation(0), json);
     }
     catch (Exception e)
     {
         return(new StatusCodeImplementation(-1), null);
     }
 }
        public object CreateClass(IUrl url)
        {
            List <Dictionary <string, dynamic> > lst = new List <Dictionary <string, dynamic> >();

            dynamic stuff = JsonConvert.DeserializeObject(url.GetUrlContext().Body);

            foreach (JObject jObj in stuff)
            {
                Dictionary <string, dynamic> dict = new Dictionary <string, dynamic>();

                var rootProperties = jObj.Children().OfType <JProperty>().Select(p => p.Name).ToArray();
                foreach (var property in rootProperties)
                {
                    dict.Add(property, jObj.Property(property).Value.ToString());
                }
                lst.Add(dict);
            }

            return((from l in lst select new DynamicDictionaryWrapper(l)).ToList());
        }