/[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/10 09:10:42	96
+++ trunk/libxmltv/Core/XMLTVProgram.cs	2013/03/10 11:35:26	105
@@ -54,7 +54,8 @@
         }
 
         #region Property Dictionary Support
-        public PropertyDictionary MetaData { get; private set; }
+        private PropertyDictionary _MetaData;
+        public PropertyDictionary MetaData { get { return _MetaData; } private set { _MetaData = value; } }
         #endregion
 
         #endregion
@@ -62,9 +63,9 @@
         {
             return string.Format("{0}: {1} - {2} ({3}) ['{4}' <==> '{5}']",
                 MetaData["Id"].ToString(),
-                 MetaData[(XMLTVConstants.Programs.ProgramTitle)].ToString(),
-                 MetaData[(XMLTVConstants.Programs.ProgramSubTitle)].ToString(),
-                 MetaData[(XMLTVConstants.Programs.ProgramChannelId)].ToString(),
+                 MetaData[XMLTVConstants.Programs.ProgramTitle].ToString(),
+                 MetaData[XMLTVConstants.Programs.ProgramSubTitle].ToString(),
+                 MetaData[XMLTVConstants.Programs.ProgramChannelId].ToString(),
                 ((DateTime)MetaData[XMLTVConstants.Programs.ProgramStart]).ToString("yyyy/MM/dd hh:mm tt"),
                 ((DateTime)MetaData[XMLTVConstants.Programs.ProgramStop]).ToString("yyyy/MM/dd hh:mm tt"));
         }
@@ -177,38 +178,35 @@
             }
             if (handler_type == null)
             {
-                StringBuilder node_builder = new StringBuilder();
-                node_builder.AppendFormat("<{0} ", node.Name);
-                if (node.HasAttributes) { foreach (var attribute in node.Attributes()) { node_builder.AppendFormat("{0}=\"{1}\" ", attribute.Name, attribute.Value); } }
-                string node_text = string.Format("{0}>", node_builder.ToString().TrimEnd(new char[] { ' ' }));
-                xmltv_logger.Verbose.Warn.WriteLine("Ignoring unhandled extra meta-data: {0}", node_text);
+                try
+                {
+                    raw_instance = Activator.CreateInstance(typeof(UnhandledExtraMetaData), flags, null, new object[] { this, node }, culture);
+                }
+                catch (Exception ex) { throw ex; }
+
+                if (raw_instance == null)
+                {
+                    StringBuilder node_builder = new StringBuilder();
+                    node_builder.AppendFormat("<{0} ", node.Name);
+                    if (node.HasAttributes) { foreach (var attribute in node.Attributes()) { node_builder.AppendFormat("{0}=\"{1}\" ", attribute.Name, attribute.Value); } }
+                    string node_text = string.Format("{0}>", node_builder.ToString().TrimEnd(new char[] { ' ' }));
+                    xmltv_logger.Verbose.Warn.WriteLine("Ignoring unhandled extra meta-data: {0}", node_text);
+                }
             }
             else
             {
-                raw_instance = Activator.CreateInstance(handler_type, flags, null, new object[] { this, node }, culture);
+                try
+                {
+                    raw_instance = Activator.CreateInstance(handler_type, flags, null, new object[] { this, node }, culture);
+                }
+                catch (Exception ex) { throw ex; }
             }
         }
 
 
 
-        #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.Value != null)
-                {
-                    instance.MetaData.AddProperty(XMLTVConstants.Programs.ProgramTitle, node.Value);
-                    xmltv_logger.Verbose.Debug.WriteLine("\tprogram_title: {0}", node.Value);
-                }                
-            }
-        }
-        #endregion
-        #region program stop/start/channel (programme)
+        #region sub-classes       
+        #region programme: stop/start/channelid
         private class programme : XMLTVBase<XMLTVProgram>
         {
             public programme() : base(null, XMLTVConstants.Programs.RootElement) { }
@@ -239,8 +237,23 @@
             }
         }
         #endregion
-
-        #region sub title
+        #region 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.Value != null)
+                {
+                    instance.MetaData.AddProperty(XMLTVConstants.Programs.ProgramTitle, node.Value);
+                    xmltv_logger.Verbose.Debug.WriteLine("\tprogram_title: {0}", node.Value);
+                }
+            }
+        }
+        #endregion
+        #region sub-title
         private class subtitle : XMLTVBase<XMLTVProgram>
         {
             public subtitle() : base(null, XMLTVConstants.Programs.ProgramSubTitle) { }
@@ -256,7 +269,7 @@
             }
         }
         #endregion
-        #region sub title
+        #region description
         private class description : XMLTVBase<XMLTVProgram>
         {
             public description() : base(null, XMLTVConstants.Programs.ProgramDescription) { }
@@ -272,6 +285,33 @@
             }
         }
         #endregion
+
+        #region UnhandledExtraMetaData
+        private class UnhandledExtraMetaData : XMLTVBase<XMLTVProgram>
+        {
+            public UnhandledExtraMetaData() : base(null, null) { }
+            public UnhandledExtraMetaData(XMLTVProgram instance, XElement node)
+                : base(instance, null)
+            {
+                if (node == null) { throw new NullReferenceException("The node instance was null"); }
+                //if (node.Value != null)
+                //{
+                //    instance.MetaData.AddProperty(XMLTVConstants.Programs.ProgramDescription, node.Value);
+                //    xmltv_logger.Verbose.Debug.WriteLine("\tprogram_description: {0}", node.Value);
+                //}
+                xmltv_logger.Verbose.Debug.WriteLine("Parsng unhandled extra meta-data: {0}", node.Name.ToString());
+
+                if (this.GetInstance() != null)
+                {
+                    if (!instance.MetaData.ContainsProperty(XMLTVConstants.Programs.ProgramExtraMetaData))
+                    {
+                        instance.MetaData.AddProperty(XMLTVConstants.Programs.ProgramExtraMetaData, null);
+                    }
+                }
+
+            }
+        }
+        #endregion
         #endregion
     }
 }

 

  ViewVC Help
Powered by ViewVC 1.1.22