From: <sam...@us...> - 2006-06-01 07:02:09
|
Revision: 10 Author: samuel337 Date: 2006-06-01 00:02:01 -0700 (Thu, 01 Jun 2006) ViewCVS: http://svn.sourceforge.net/mp-webinterface/?rev=10&view=rev Log Message: ----------- Fixed problems with methods returning TV Channel related information Modified Paths: -------------- trunk/source/ECP2WebService/App_Code/Service.cs Modified: trunk/source/ECP2WebService/App_Code/Service.cs =================================================================== --- trunk/source/ECP2WebService/App_Code/Service.cs 2006-05-29 07:36:04 UTC (rev 9) +++ trunk/source/ECP2WebService/App_Code/Service.cs 2006-06-01 07:02:01 UTC (rev 10) @@ -269,12 +269,22 @@ List<MediaPortal.TV.Database.TVChannel> chnList; chnList = GetEMPH().GetChannels(); + if (chnList.Count == 0) return ""; + + // As CurrentProgram is not necessary, set its XMLIgnore attribute to true + System.Xml.Serialization.XmlAttributeOverrides xmlOverrides = new System.Xml.Serialization.XmlAttributeOverrides(); + System.Xml.Serialization.XmlAttributes xmlAttributes; + + xmlAttributes = new System.Xml.Serialization.XmlAttributes(); + xmlAttributes.XmlIgnore = true; + xmlOverrides.Add(typeof(MediaPortal.TV.Database.TVChannel), "CurrentProgram", xmlAttributes); + System.Text.StringBuilder sb = new System.Text.StringBuilder(); System.IO.StringWriter sw = new System.IO.StringWriter(sb); System.Text.StringBuilder sbXML = new System.Text.StringBuilder(); System.IO.StringWriter swXML = new System.IO.StringWriter(sbXML); System.Xml.XmlTextWriter xw = new System.Xml.XmlTextWriter(swXML); - System.Xml.Serialization.XmlSerializer xs = new System.Xml.Serialization.XmlSerializer(typeof(MediaPortal.TV.Database.TVChannel)); + System.Xml.Serialization.XmlSerializer xs = new System.Xml.Serialization.XmlSerializer(typeof(MediaPortal.TV.Database.TVChannel),xmlOverrides); MediaPortal.TV.Database.TVChannel chn; xw.WriteStartDocument(); @@ -283,7 +293,7 @@ for (int i = 0; i <= chnList.Count - 1; i++) { - chn = (MediaPortal.TV.Database.TVChannel)(chnList[i]); + chn = (MediaPortal.TV.Database.TVChannel)chnList[i]; xs.Serialize(sw, chn); xw.WriteRaw(sb.ToString().Substring(sb.ToString().IndexOf("?>") + 2)); sb.Remove(0, sb.Length - 1); @@ -292,7 +302,7 @@ xw.WriteEndElement(); xw.WriteEndElement(); xw.WriteEndDocument(); - + return sbXML.ToString(); } @@ -302,25 +312,34 @@ MediaPortal.TV.Database.TVChannel chn; chn = GetEMPH().GetChannel(channelID); + // As CurrentProgram is not necessary, set its XMLIgnore attribute to true + System.Xml.Serialization.XmlAttributeOverrides xmlOverrides = new System.Xml.Serialization.XmlAttributeOverrides(); + System.Xml.Serialization.XmlAttributes xmlAttributes; + + xmlAttributes = new System.Xml.Serialization.XmlAttributes(); + xmlAttributes.XmlIgnore = true; + xmlOverrides.Add(typeof(MediaPortal.TV.Database.TVChannel), "CurrentProgram", xmlAttributes); + System.Text.StringBuilder sb = new System.Text.StringBuilder(); System.IO.StringWriter sw = new System.IO.StringWriter(sb); System.Text.StringBuilder sbXML = new System.Text.StringBuilder(); System.IO.StringWriter swXML = new System.IO.StringWriter(sbXML); System.Xml.XmlTextWriter xw = new System.Xml.XmlTextWriter(swXML); - System.Xml.Serialization.XmlSerializer xs = new System.Xml.Serialization.XmlSerializer(typeof(MediaPortal.TV.Database.TVChannel)); + System.Xml.Serialization.XmlSerializer xs = new System.Xml.Serialization.XmlSerializer(typeof(MediaPortal.TV.Database.TVChannel), xmlOverrides); xw.WriteStartDocument(); xw.WriteStartElement("MPData"); xw.WriteStartElement("TVChannels"); xs.Serialize(sw, chn); + xw.WriteRaw(sb.ToString().Substring(sb.ToString().IndexOf("?>") + 2)); sb.Remove(0, sb.Length - 1); xw.WriteEndElement(); xw.WriteEndElement(); xw.WriteEndDocument(); - + return sbXML.ToString(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |