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

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

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

--- trunk/libxmltv/Core/XMLTVSource.cs	2013/03/09 10:27:39	73
+++ trunk/libxmltv/Core/XMLTVSource.cs	2013/03/09 14:52:10	88
@@ -6,6 +6,7 @@
 using System.Diagnostics;
 using System.Xml.Linq;
 using System.Reflection;
+using System.IO;
 
 namespace libxmltv.Core
 {
@@ -27,18 +28,22 @@
         //    this.GeneratorUrl = generatorurl;
         //}
         public XMLTVSource()
-            : base(null, XMLTVConstants.ROOT_ELEMENT) 
+            : base(null, XMLTVConstants.Root.RootElement) 
         {
             this.SourceName = string.Empty;
             this.GeneratorName = string.Empty;
             this.GeneratorUrl = string.Empty;
         }
-        public XMLTVSource(XMLTVRuntimeInstance instance) : base(instance, XMLTVConstants.ROOT_ELEMENT)
+        public XMLTVSource(XMLTVRuntimeInstance instance)
+            : base(instance, XMLTVConstants.Root.RootElement)
         {
-            xmltv_logger.Debug.WriteLine("Creating Instance of XMLTVSource");
+            try {
+            xmltv_logger.Verbose.Debug.WriteLine("Creating Instance of XMLTVSource");
             Create();
-            xmltv_logger.Debug.WriteLine("Created Instance of XMLTVSource '{0}'", SourceName);
+            xmltv_logger.Verbose.Debug.WriteLine("Created Instance of XMLTVSource '{0}'", SourceName);
             UpdateInstance();
+            }
+            catch (IOException ex) { Debug.WriteLine(ex.ToString()); }
         }
 
         private void UpdateInstance()
@@ -48,25 +53,25 @@
             var fields = instance_type.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
             foreach (var field in fields)
             {
-                if (field.FieldType == typeof(List<IXMLTVSource>))
+                if (field.FieldType == typeof(IXMLTVSource))
                 {
                     found_field = true;
                     try
                     {
-                        xmltv_logger.Debug.WriteLine("Updating instance with source information.");
-                        field.SetValue(this.GetInstance(), new List<IXMLTVSource>() { this });                        
+                        xmltv_logger.Verbose.Debug.WriteLine("Updating instance with source information: {0}", this.ToString());
+                        field.SetValue(this.GetInstance(), this);                        
                         break;
                     }
                     catch (Exception ex)
                     {
-                        xmltv_logger.Error.WriteLine("Unable to update instance with source information.");
-                        xmltv_logger.Error.WriteLine(ex.ToString());
+                        xmltv_logger.Verbose.Error.WriteLine("Unable to update instance with source information.");
+                        xmltv_logger.Verbose.Error.WriteLine(ex.ToString());
                     }
                 }
             }
             if (!found_field)
             {
-                xmltv_logger.Error.WriteLine("Unable to update instance with source information.");
+                xmltv_logger.Verbose.Error.WriteLine("Unable to update instance with source information.");
             }
         }
 
@@ -80,7 +85,7 @@
         private void Create()
         {
             var doc = XDocument.Parse(this.GetInstance().XmlDoc);
-            Debug.Assert(doc.Root.Name == XMLTVConstants.ROOT_ELEMENT, string.Format("Expected Root Element: '{0}' but read: '{1}'", XMLTVConstants.ROOT_ELEMENT, doc.Root.Name));
+            Debug.Assert(doc.Root.Name == XMLTVConstants.Root.RootElement, string.Format("Expected Root Element: '{0}' but read: '{1}'", XMLTVConstants.Root.RootElement, doc.Root.Name));
             //xmltv_logger.Verbose.Debug.WriteLine("\tRoot: {0}", doc.Root.Name);
             var attributes = doc.Root.Attributes().ToList();
             foreach (var attribute in attributes)

 

  ViewVC Help
Powered by ViewVC 1.1.22