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

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

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

--- trunk/libxmltv/Core/XMLTVRuntimeInstance.cs	2013/03/10 12:25:54	106
+++ trunk/libxmltv/Core/XMLTVRuntimeInstance.cs	2013/03/10 12:58:40	107
@@ -55,6 +55,7 @@
             this.XmlFile_FullName = string.Empty;
             this.XmlDoc = string.Empty;
             this.OnInstanceCreated = null;
+            this.ExtraEntries = new List<IExtraMetaData>();
         }
 
         #region IXMLTVRuntimeInstance members
@@ -75,6 +76,9 @@
         public List<IXMLTVChannel> Channels { get { return _Channels; } set { _Channels = value; } }
         private List<IXMLTVProgram> _Programs;
         public List<IXMLTVProgram> Programs { get { return _Programs; } set { _Programs = value; } }
+
+        private List<IExtraMetaData> _ExtraEntries;
+        public List<IExtraMetaData> ExtraEntries { get { return _ExtraEntries; } set { _ExtraEntries = value; } }
         #endregion       
         #region IOnInstanceCreated members
         [NonSerialized]
@@ -405,18 +409,47 @@
                     }
                 }
             }
-            if (handler_type == null) 
+            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[] { ' ' }));
-                throw new Exception(string.Format("Unable to find a compatible handler to parse node: {0}", node_text)); 
+                try
+                {
+                    raw_instance = Activator.CreateInstance(typeof(UnhandledNodeData), flags, null, new object[] { gInstance, 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[] { ' ' }));
+                    throw new Exception(string.Format("Unable to find a compatible handler to parse node: {0}", node_text));
+                }
+            }
+            else
+            {
+                xmltv_logger.Verbose.Debug.WriteLine("Created handler for node: '{0}'", node_name.ToString());
+                raw_instance = Activator.CreateInstance(handler_type, flags, null, new object[] { gInstance, node }, culture);                
             }
-            xmltv_logger.Verbose.Debug.WriteLine("Created handler for node: '{0}'", node_name.ToString());
-            raw_instance = Activator.CreateInstance(handler_type, flags, null, new object[] { gInstance, node }, culture);
             return true;
         }
+        #region UnhandledExtraMetaData
+        private class UnhandledNodeData : XMLTVBase<XMLTVRuntimeInstance>
+        {
+            public UnhandledNodeData() : base(null, null) { }
+            public UnhandledNodeData(XMLTVRuntimeInstance instance, XElement node)
+                : base(instance, null)
+            {
+                if (node == null) { throw new NullReferenceException("The node instance was null"); }
+                xmltv_logger.Verbose.Debug.WriteLine("Parsng unhandled node data: {0}", node.Name.ToString());
+                if (this.GetInstance() != null)
+                {
+                    ExtraMetaData data = new ExtraMetaData(node);
+                    instance.ExtraEntries.Add(data);
+                }
+            }
+        }
+        #endregion
         
     }
 }

 

  ViewVC Help
Powered by ViewVC 1.1.22