/[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 36 by william, Fri Mar 8 02:13:59 2013 UTC revision 69 by william, Sat Mar 9 01:36:49 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// : IXMLTV_LOADER      internal class XMLTVLoader : IDisposable
14      {      {
15          private string xmlfile = string.Empty;          private string xmlfile = string.Empty;
16            internal static void CreateInstance(string xml_file, XMLTVRuntimeInstance xmltv)
17            {
18                using (XMLTVLoader g = new XMLTVLoader(xml_file, xmltv)) { }            
19            }
20          private XMLTVRuntimeInstance instance;          private XMLTVRuntimeInstance instance;
21          public XMLTVLoader(string xml_file, XMLTVRuntimeInstance xmltv)          protected XMLTVLoader(string xml_file, XMLTVRuntimeInstance xmltv)
22          {          {
23              XMLTV_LOGGER.Log.Verbose.Debug.WriteLine("Creating Instance of XMLTVLoader");              xmltv_logger.Debug.WriteLine("Creating Instance of XMLTVLoader");
24              //string _xmltv;              //string _xmltv;
25              //if (!Internals.VerifyInstance<string>(xmltv, out _xmltv)) { return; }              //if (!Internals.VerifyInstance<string>(xmltv, out _xmltv)) { return; }
26              //xmlfile = _xmltv;              //xmlfile = _xmltv;
# Line 31  namespace libxmltv.Core Line 36  namespace libxmltv.Core
36    
37          private void LoadXml()          private void LoadXml()
38          {          {
39              XMLTV_LOGGER.Log.Info.WriteLine("Loading XMLTV File: {0}", instance.XmlFile.Name);              xmltv_logger.Info.WriteLine("Loading XMLTV File: {0}", instance.XmlFile.Name);
40              //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!");
41              try              try
42              {              {
43                  instance.XmlDoc = XDocument.Load(instance.XmlFile.FullName);                  var document = XDocument.Load(instance.XmlFile.FullName);
44                    using (var ms = new MemoryStream())
45                    using (var xw = new XmlTextWriter(ms, Encoding.UTF8))
46                    {
47                        document.Save(xw);
48                        xw.Flush();
49                        StreamReader sr = new StreamReader(ms);
50                        ms.Seek(0, SeekOrigin.Begin);
51                        instance.XmlDoc = sr.ReadToEnd();
52                    }
53                    document = null;
54              }              }
55              catch (Exception ex)              catch (Exception ex)
56              {              {
57                  XMLTV_LOGGER.Log.Error.WriteLine("Failed to load XMLTV File: {0}", instance.XmlFile.Name);                  xmltv_logger.Error.WriteLine("Failed to load XMLTV File: {0}", instance.XmlFile.Name);
58                  XMLTV_LOGGER.Log.Error.WriteLine(ex.GetBaseException().ToString());                  xmltv_logger.Error.WriteLine(ex.GetBaseException().ToString());
59              }              }
60          }          }
61    
62            public void Dispose()
63            {
64                //throw new NotImplementedException();
65            }
66    
67            
68      }      }
69  }  }

Legend:
Removed from v.36  
changed lines
  Added in v.69

  ViewVC Help
Powered by ViewVC 1.1.22