/[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

revision 44 by william, Fri Mar 8 03:36:44 2013 UTC revision 73 by william, Sat Mar 9 10:27:39 2013 UTC
# Line 6  using libxmltv.Interfaces; Line 6  using libxmltv.Interfaces;
6  using System.IO;  using System.IO;
7  using Enterprise.Logging;  using Enterprise.Logging;
8  using System.Xml.Linq;  using System.Xml.Linq;
9    using System.Xml;
10    
11  namespace libxmltv.Core  namespace libxmltv.Core
12  {    {
13      internal class XMLTVLoader : IDisposable      internal class XMLTVLoader : XMLTVBase<XMLTVRuntimeInstance>, IDisposable
14      {      {
15          private string xmlfile = string.Empty;          private string xmlfile = string.Empty;
16          internal static void CreateInstance(string xml_file, XMLTVRuntimeInstance xmltv)          //internal static void CreateInstance(string xml_file, XMLTVRuntimeInstance xmltv)
17            //{
18            //    using (XMLTVLoader g = new XMLTVLoader(xml_file, xmltv)) { }            
19            //}
20            protected XMLTVLoader(string xml_file, XMLTVRuntimeInstance instance)
21                : base(instance, xml_file)
22          {          {
23              using (XMLTVLoader g = new XMLTVLoader(xml_file, xmltv)) { }                          xmltv_logger.Debug.WriteLine("Creating Instance of XMLTVLoader");
24          }             var fi = new FileInfo(xml_file);
25          private XMLTVRuntimeInstance instance;             this.GetInstance().XmlFile_FullName = fi.FullName;
26          protected XMLTVLoader(string xml_file, XMLTVRuntimeInstance xmltv)             this.GetInstance().XmlFile_Name = fi.Name;
         {  
             XMLTV_LOGGER.Log.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);  
27              LoadXml();              LoadXml();
28                xmltv_logger.Debug.WriteLine("Created Instance of XMLTVLoader");
29          }          }
         //#region IXMLTV_LOADER  
         //public FileInfo XmlFile { get { return new FileInfo(xmlfile); } }  
         //public XDocument XmlDoc { get; private set; }  
         //#endregion  
30    
31          private void LoadXml()          private void LoadXml()
32          {          {
33              XMLTV_LOGGER.Log.Info.WriteLine("Loading XMLTV File: {0}", instance.XmlFile.Name);              xmltv_logger.Info.WriteLine("Loading XMLTV File: {0}", this.GetInstance().XmlFile_Name);
34              //XMLTV_LOGGER.Log.Warn.WriteLine("XML File Loading has not been implemented yet!");              //xmltv_logger.Warn.WriteLine("XML File Loading has not been implemented yet!");
35              try              try
36              {              {
37                  instance.XmlDoc = XDocument.Load(instance.XmlFile.FullName);                  var document = XDocument.Load(this.GetInstance().XmlFile_FullName);
38                    using (var ms = new MemoryStream())
39                    using (var xw = new XmlTextWriter(ms, Encoding.UTF8))
40                    {
41                        document.Save(xw);
42                        xw.Flush();
43                        StreamReader sr = new StreamReader(ms);
44                        ms.Seek(0, SeekOrigin.Begin);
45                        this.GetInstance().XmlDoc = sr.ReadToEnd();
46                    }
47                    document = null;
48              }              }
49              catch (Exception ex)              catch (Exception ex)
50              {              {
51                  XMLTV_LOGGER.Log.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);
52                  XMLTV_LOGGER.Log.Error.WriteLine(ex.GetBaseException().ToString());                  xmltv_logger.Error.WriteLine(ex.GetBaseException().ToString());
53              }              }
54          }          }
55    
# Line 52  namespace libxmltv.Core Line 57  namespace libxmltv.Core
57          {          {
58              //throw new NotImplementedException();              //throw new NotImplementedException();
59          }          }
60    
61            
62      }      }
63  }  }

Legend:
Removed from v.44  
changed lines
  Added in v.73

  ViewVC Help
Powered by ViewVC 1.1.22