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

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

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

--- trunk/libxmltv/Core/XMLTVLoader.cs	2013/03/08 10:19:32	55
+++ trunk/libxmltv/Core/XMLTVLoader.cs	2013/03/09 10:27:39	73
@@ -9,38 +9,32 @@
 using System.Xml;
 
 namespace libxmltv.Core
-{   
-    internal class XMLTVLoader : IDisposable
+{
+    internal class XMLTVLoader : XMLTVBase<XMLTVRuntimeInstance>, IDisposable
     {
         private string xmlfile = string.Empty;
-        internal static void CreateInstance(string xml_file, XMLTVRuntimeInstance xmltv)
+        //internal static void CreateInstance(string xml_file, XMLTVRuntimeInstance xmltv)
+        //{
+        //    using (XMLTVLoader g = new XMLTVLoader(xml_file, xmltv)) { }            
+        //}
+        protected XMLTVLoader(string xml_file, XMLTVRuntimeInstance instance)
+            : base(instance, xml_file)
         {
-            using (XMLTVLoader g = new XMLTVLoader(xml_file, xmltv)) { }            
-        }
-        private XMLTVRuntimeInstance instance;
-        protected XMLTVLoader(string xml_file, XMLTVRuntimeInstance xmltv)
-        {
-            xmltv_logger.Verbose.Debug.WriteLine("Creating Instance of XMLTVLoader");
-            //string _xmltv;
-            //if (!Internals.VerifyInstance<string>(xmltv, out _xmltv)) { return; }
-            //xmlfile = _xmltv;
-            //LoadXml();
-            instance = xmltv;
-            instance.XmlFile = new FileInfo(xml_file);
+            xmltv_logger.Debug.WriteLine("Creating Instance of XMLTVLoader");
+           var fi = new FileInfo(xml_file);
+           this.GetInstance().XmlFile_FullName = fi.FullName;
+           this.GetInstance().XmlFile_Name = fi.Name;
             LoadXml();
+            xmltv_logger.Debug.WriteLine("Created Instance of XMLTVLoader");
         }
-        //#region IXMLTV_LOADER
-        //public FileInfo XmlFile { get { return new FileInfo(xmlfile); } }
-        //public XDocument XmlDoc { get; private set; }
-        //#endregion
 
         private void LoadXml()
         {
-            xmltv_logger.Info.WriteLine("Loading XMLTV File: {0}", instance.XmlFile.Name);
+            xmltv_logger.Info.WriteLine("Loading XMLTV File: {0}", this.GetInstance().XmlFile_Name);
             //xmltv_logger.Warn.WriteLine("XML File Loading has not been implemented yet!");
             try
             {
-                var document = XDocument.Load(instance.XmlFile.FullName);
+                var document = XDocument.Load(this.GetInstance().XmlFile_FullName);
                 using (var ms = new MemoryStream())
                 using (var xw = new XmlTextWriter(ms, Encoding.UTF8))
                 {
@@ -48,13 +42,13 @@
                     xw.Flush();
                     StreamReader sr = new StreamReader(ms);
                     ms.Seek(0, SeekOrigin.Begin);
-                    instance.XmlDoc = sr.ReadToEnd();
+                    this.GetInstance().XmlDoc = sr.ReadToEnd();
                 }
                 document = null;
             }
             catch (Exception ex)
             {
-                xmltv_logger.Error.WriteLine("Failed to load XMLTV File: {0}", instance.XmlFile.Name);
+                xmltv_logger.Error.WriteLine("Failed to load XMLTV File: {0}", this.GetInstance().XmlFile_Name);
                 xmltv_logger.Error.WriteLine(ex.GetBaseException().ToString());
             }
         }

 

  ViewVC Help
Powered by ViewVC 1.1.22