Example #1
0
 private void debug_fav_set(string data)
 {
     try
     {
         List<Favorite> lf = new List<Favorite>();
         lf = acc.favorite_channel;
         XmlDocument doc = new XmlDocument();
         doc.LoadXml(data);
         foreach (XmlElement xitem in doc.DocumentElement.SelectNodes("//message"))
         {
             Boolean isdel = false;
             string id_channel = "";
             XmlDocument mdoc = new XmlDocument();
             mdoc.LoadXml("<root>" + xitem.InnerXml + "</root>");
             foreach (XmlElement titem in mdoc.DocumentElement.SelectNodes("//text"))
             {
                 if (titem.InnerText == "Favorite channel was set")
                 {
                     isdel = false;
                 }
                 else isdel = true;
             }
             foreach (XmlElement link in mdoc.DocumentElement.SelectNodes("//channel"))
             {
                 id_channel = link.InnerText;
             }
             if (isdel)
             {
                 foreach (Favorite far in lf)
                 {
                     if (far.id_channel == id_channel)
                     {
                         lf.Remove(far);
                         break;
                     }
                 }
             }
             else
             {
                 Favorite fav = new Favorite();
                 fav.id_channel = id_channel;
                 lf.Add(fav);
             }
         }
         acc.favorite_channel = lf;
     }
     catch (Exception)
     {
         throw new System.InvalidOperationException("Error to set/delete favorite channel"); 
     }
 }
Example #2
0
 private List<Favorite> debug_fav(string data)
 {
     try
     {
         List<Favorite> lf = new List<Favorite>();
         XmlDocument doc = new XmlDocument();
         doc.LoadXml(data);
         foreach (XmlElement xitem in doc.DocumentElement.SelectNodes("//item"))
         {
             Favorite fav = new Favorite();
             XmlDocument idoc = new XmlDocument();
             idoc.LoadXml("<root>" + xitem.InnerXml + "</root>");
             foreach (XmlElement link in idoc.DocumentElement.SelectNodes("//channel_id"))
             {
                 fav.id_channel = link.InnerText;
             }
             lf.Add(fav);
         }
         return lf;
     }
     catch (Exception)
     {
         throw new System.InvalidOperationException("rror to get favorite channel list");
     }
 }