Пример #1
0
 int GetCount(string xml)
 {
     try
     {
         var json = new System.Web.Script.Serialization.JavaScriptSerializer().DeserializeObject(xml) as Dictionary <string, object>;
         while (json != null && !json.ContainsKey("engagement"))
         {
             json = json.ElementAt(0).Value as Dictionary <string, object>;
         }
         if (json != null)
         {
             // get engagements count
             var count = (int)((Dictionary <string, object>)json["engagement"])["count"];
             return(count);
         }
     }
     catch
     {
         // in case if facebook changes api or something else of this kind. We don't need to break application
     }
     return(0);
 }