/[xmltv_parser]/trunk/libxmltv/Core/XMLTVChannel.cs
ViewVC logotype

Diff of /trunk/libxmltv/Core/XMLTVChannel.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 74 by william, Sat Mar 9 11:06:39 2013 UTC revision 83 by william, Sat Mar 9 12:41:07 2013 UTC
# Line 5  using System.Text; Line 5  using System.Text;
5  using libxmltv.Interfaces;  using libxmltv.Interfaces;
6  using System.Xml.Linq;  using System.Xml.Linq;
7  using System.Reflection;  using System.Reflection;
8    using System.IO;
9    using System.Diagnostics;
10    
11  namespace libxmltv.Core  namespace libxmltv.Core
12  {  {
13      [Serializable]      [Serializable]
14      internal class XMLTVChannel : XMLTVBase<XMLTVRuntimeInstance>, IXMLTVChannel      internal class XMLTVChannel : XMLTVBase<XMLTVRuntimeInstance>, IXMLTVChannel
15      {      {
16          public XMLTVChannel() : base(null,XMLTVConstants.CHANNEL_ELEMENT)          public XMLTVChannel()
17                : base(null, XMLTVConstants.CHANNEL_ELEMENT)
18          {          {
19              Id = string.Empty;              Id = string.Empty;
20              Number = 0;              Number = 0;
# Line 21  namespace libxmltv.Core Line 24  namespace libxmltv.Core
24          public XMLTVChannel(XMLTVRuntimeInstance instance, XElement node)          public XMLTVChannel(XMLTVRuntimeInstance instance, XElement node)
25              : base(instance, XMLTVConstants.CHANNEL_ELEMENT)              : base(instance, XMLTVConstants.CHANNEL_ELEMENT)
26          {          {
27              xmltv_logger.Verbose.Debug.WriteLine("Creating Instance of XMLTVChannel");              try
28              // get the channel id              {
29              Id = node.Attribute(XMLTVConstants.Channels.ChannelId).Value;                  xmltv_logger.Verbose.Debug.WriteLine("Creating Instance of XMLTVChannel");
30              xmltv_logger.Verbose.Debug.WriteLine("\tchannel_id: {0}", Id);                  Create(node);
31              var names = node.Descendants(XMLTVConstants.Channels.ChannelDisplayName).ToList();                  xmltv_logger.Verbose.Debug.WriteLine("Created Instance of XMLTVChannel");
32              Number = Convert.ToInt32(names[1].Value);                  UpdateInstance();
33              xmltv_logger.Verbose.Debug.WriteLine("\tchannel_number: {0}", Number);              }
34              CallSign = names[2].Value;              catch (IOException ex) { Debug.WriteLine(ex.ToString()); }
             xmltv_logger.Verbose.Debug.WriteLine("\tchannel_callsign: {0}", CallSign);  
             Name = names[3].Value;  
             xmltv_logger.Verbose.Debug.WriteLine("\tchannel_name: {0}", Name);  
             xmltv_logger.Verbose.Debug.WriteLine("Created Instance of XMLTVChannel");  
             UpdateInstance();              
35          }          }
36          #region IXMLTVChannel members          #region IXMLTVChannel members
37          public string Id { get; private set; }          public string Id { get; private set; }
# Line 58  namespace libxmltv.Core Line 56  namespace libxmltv.Core
56                      found_field = true;                      found_field = true;
57                      try                      try
58                      {                      {
                         xmltv_logger.Verbose.Debug.WriteLine("Updating instance with channel information: {0}", this.ToString());  
                         //field.SetValue(this.GetInstance(), new List<IXMLTVChannel>() { this });  
   
59                          var list = (List<IXMLTVChannel>)field.GetValue(this.GetInstance());                          var list = (List<IXMLTVChannel>)field.GetValue(this.GetInstance());
60                          list.Add(this);                          list.Add(this);
61                            xmltv_logger.Verbose.Debug.WriteLine("Updating instance with channel information: {0}", this.ToString());
62                          field.SetValue(this.GetInstance(), list);                          field.SetValue(this.GetInstance(), list);
63                          break;                          break;
64                      }                      }
# Line 78  namespace libxmltv.Core Line 74  namespace libxmltv.Core
74                  xmltv_logger.Verbose.Error.WriteLine("Unable to update instance with channel information.");                  xmltv_logger.Verbose.Error.WriteLine("Unable to update instance with channel information.");
75              }              }
76          }          }
77    
78            private void Create(XElement node)
79            {
80                // get the channel id
81                Id = node.Attribute(XMLTVConstants.Channels.ChannelId).Value;
82                xmltv_logger.Verbose.Debug.WriteLine("\tchannel_id: {0}", Id);
83                var names = node.Descendants(XMLTVConstants.Channels.ChannelDisplayName).ToList();
84                Number = Convert.ToInt32(names[1].Value);
85                xmltv_logger.Verbose.Debug.WriteLine("\tchannel_number: {0}", Number);
86                CallSign = names[2].Value;
87                xmltv_logger.Verbose.Debug.WriteLine("\tchannel_callsign: {0}", CallSign);
88                Name = names[3].Value;
89                xmltv_logger.Verbose.Debug.WriteLine("\tchannel_name: {0}", Name);
90            }
91      }      }
92    
93  }  }

Legend:
Removed from v.74  
changed lines
  Added in v.83

  ViewVC Help
Powered by ViewVC 1.1.22