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

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

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

--- trunk/libxmltv/Core/XMLTVProgram.cs	2013/03/09 14:33:18	87
+++ trunk/libxmltv/Core/XMLTVProgram.cs	2013/03/09 14:58:09	89
@@ -14,13 +14,14 @@
     [Serializable]
     internal class XMLTVProgram : XMLTVBase<XMLTVRuntimeInstance>, IXMLTVProgram
     {
-        public XMLTVProgram() : base(null,XMLTVConstants.PROGRAM_ELEMENT)
+        public XMLTVProgram()
+            : base(null, XMLTVConstants.Programs.RootElement)
         {
             InternalDictionaryAddKnownProperties();
          
         }
         public XMLTVProgram(XMLTVRuntimeInstance instance, XElement node)
-            : base(instance, XMLTVConstants.PROGRAM_ELEMENT)
+            : base(instance, XMLTVConstants.Programs.RootElement)
         {
             InternalDictionaryAddKnownProperties();
             try {
@@ -166,7 +167,7 @@
             //    if (!this.Stop.Equals(new DateTime())) { xmltv_logger.Verbose.Debug.WriteLine("\tprogram_stop: {0}", stop); }
 
             //    var channelid = node.Attribute(XMLTVConstants.Programs.ProgramChannelId);
-            //    if (!string.IsNullOrEmpty(this.Description)) { xmltv_logger.Verbose.Debug.WriteLine("\tprogram_channelid: {0}", channelid); }
+            //    if (!string.IsNullOrEmpty(this.channelid)) { xmltv_logger.Verbose.Debug.WriteLine("\tprogram_channelid: {0}", channelid); }
             //    IXMLTVChannel channel = new XMLTVChannel();
             //    string _channelid = channelid == null ? string.Empty : channelid.Value;
             //    this.Channel = this.GetInstance().Channels.Find(m => m.Id == _channelid);
@@ -280,19 +281,86 @@
 
 
         #region sub-classes
+        #region program title
         private class title : XMLTVBase<XMLTVProgram>
         {
             public title() : base(null, XMLTVConstants.Programs.ProgramTitle) { }
             public title(XMLTVProgram instance, XElement node)
                 : base(instance, XMLTVConstants.Programs.ProgramTitle)
             {                
-                if(node == null){throw new NullReferenceException("The node instance was null");}
+                if(node == null){throw new NullReferenceException("The node instance was null");}                
                 if (node.Value != null)
                 {
                     instance.AddProperty(XMLTVConstants.Programs.ProgramTitle, node.Value);
+                    xmltv_logger.Verbose.Debug.WriteLine("\tprogram_title: {0}", node.Value);
+                }                
+            }
+        }
+        #endregion
+        #region program stop/start/channel (programme)
+        private class programme : XMLTVBase<XMLTVProgram>
+        {
+            public programme() : base(null, XMLTVConstants.Programs.RootElement) { }
+            public programme(XMLTVProgram instance, XElement node)
+                : base(instance, XMLTVConstants.Programs.RootElement)
+            {
+                if (node == null) { throw new NullReferenceException("The node instance was null"); }
+                if (node.HasAttributes)
+                {                    
+                    var start = node.Attribute(XMLTVConstants.Programs.ProgramStart);
+                    var t_start = start == null ? new DateTime() : ParseDate(start.Value);
+                    if (!t_start.Equals(new DateTime())) { xmltv_logger.Verbose.Debug.WriteLine("\tprogram_start: {0}", start); }
+                    instance.AddProperty(XMLTVConstants.Programs.ProgramStart, t_start);
+
+                    var stop = node.Attribute(XMLTVConstants.Programs.ProgramStop);
+                    var t_stop = stop == null ? new DateTime() : ParseDate(stop.Value);
+                    if (!t_stop.Equals(new DateTime())) { xmltv_logger.Verbose.Debug.WriteLine("\tprogram_stop: {0}", stop); }
+                    instance.AddProperty(XMLTVConstants.Programs.ProgramStop, t_stop);
+
+                    var channelid = node.Attribute(XMLTVConstants.Programs.ProgramChannelId);
+                    if (channelid != null)
+                    {
+                        if (!string.IsNullOrEmpty(channelid.Value)) { xmltv_logger.Verbose.Debug.WriteLine("\tprogram_channelid: {0}", channelid.Value); }
+                        instance.AddProperty(XMLTVConstants.Programs.ProgramChannelId, channelid.Value);
+                    }
+                    
                 }
             }
         }
         #endregion
+
+        #region sub title
+        private class subtitle : XMLTVBase<XMLTVProgram>
+        {
+            public subtitle() : base(null, XMLTVConstants.Programs.ProgramSubTitle) { }
+            public subtitle(XMLTVProgram instance, XElement node)
+                : base(instance, XMLTVConstants.Programs.ProgramSubTitle)
+            {
+                if (node == null) { throw new NullReferenceException("The node instance was null"); }
+                if (node.Value != null)
+                {
+                    instance.AddProperty(XMLTVConstants.Programs.ProgramSubTitle, node.Value);
+                    xmltv_logger.Verbose.Debug.WriteLine("\tprogram_subtitle: {0}", node.Value);
+                }
+            }
+        }
+        #endregion
+        #region sub title
+        private class description : XMLTVBase<XMLTVProgram>
+        {
+            public description() : base(null, XMLTVConstants.Programs.ProgramDescription) { }
+            public description(XMLTVProgram instance, XElement node)
+                : base(instance, XMLTVConstants.Programs.ProgramDescription)
+            {
+                if (node == null) { throw new NullReferenceException("The node instance was null"); }
+                if (node.Value != null)
+                {
+                    instance.AddProperty(XMLTVConstants.Programs.ProgramDescription, node.Value);
+                    xmltv_logger.Verbose.Debug.WriteLine("\tprogram_description: {0}", node.Value);
+                }
+            }
+        }
+        #endregion
+        #endregion
     }
 }

 

  ViewVC Help
Powered by ViewVC 1.1.22