/[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 46 by william, Fri Mar 8 04:01:25 2013 UTC revision 81 by william, Sat Mar 9 12:23:27 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)          public XMLTVLoader(string xml_file) : base(null, xml_file) { }
17            protected XMLTVLoader(string xml_file, XMLTVRuntimeInstance instance)
18                : base(instance, xml_file)
19          {          {
20              using (XMLTVLoader g = new XMLTVLoader(xml_file, xmltv)) { }                          xmltv_logger.Debug.WriteLine("Creating Instance of XMLTVLoader");
21          }             var fi = new FileInfo(xml_file);
22          private XMLTVRuntimeInstance instance;             this.GetInstance().XmlFile_FullName = fi.FullName;
23          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);  
24              LoadXml();              LoadXml();
25                xmltv_logger.Debug.WriteLine("Created Instance of XMLTVLoader");
26          }          }
         //#region IXMLTV_LOADER  
         //public FileInfo XmlFile { get { return new FileInfo(xmlfile); } }  
         //public XDocument XmlDoc { get; private set; }  
         //#endregion  
27    
28          private void LoadXml()          private void LoadXml()
29          {          {
30              xmltv_logger.Log.Info.WriteLine("Loading XMLTV File: {0}", instance.XmlFile.Name);              xmltv_logger.Info.WriteLine("Loading XMLTV File: {0}", this.GetInstance().XmlFile_Name);
31              //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!");
32              try              try
33              {              {
34                  instance.XmlDoc = XDocument.Load(instance.XmlFile.FullName);                  var document = XDocument.Load(this.GetInstance().XmlFile_FullName);
35                    using (var ms = new MemoryStream())
36                    using (var xw = new XmlTextWriter(ms, Encoding.UTF8))
37                    {
38                        document.Save(xw);
39                        xw.Flush();
40                        StreamReader sr = new StreamReader(ms);
41                        ms.Seek(0, SeekOrigin.Begin);
42                        this.GetInstance().XmlDoc = sr.ReadToEnd();
43                    }
44                    document = null;
45              }              }
46              catch (Exception ex)              catch (Exception ex)
47              {              {
48                  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);
49                  xmltv_logger.Log.Error.WriteLine(ex.GetBaseException().ToString());                  xmltv_logger.Error.WriteLine(ex.GetBaseException().ToString());
50              }              }
51          }          }
52    
# Line 52  namespace libxmltv.Core Line 54  namespace libxmltv.Core
54          {          {
55              //throw new NotImplementedException();              //throw new NotImplementedException();
56          }          }
57    
58            
59      }      }
60  }  }

Legend:
Removed from v.46  
changed lines
  Added in v.81

  ViewVC Help
Powered by ViewVC 1.1.22