ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/xmltv_parser/trunk/libxmltv/Core/XMLTVLoader.cs
Revision: 44
Committed: Fri Mar 8 03:36:44 2013 UTC (10 years, 6 months ago) by william
File size: 1982 byte(s)
Log Message:

File Contents

# User Rev Content
1 william 11 using System;
2     using System.Collections.Generic;
3     using System.Linq;
4     using System.Text;
5     using libxmltv.Interfaces;
6     using System.IO;
7 william 14 using Enterprise.Logging;
8 william 19 using System.Xml.Linq;
9 william 11
10     namespace libxmltv.Core
11 william 22 {
12 william 44 internal class XMLTVLoader : IDisposable
13 william 11 {
14     private string xmlfile = string.Empty;
15 william 44 internal static void CreateInstance(string xml_file, XMLTVRuntimeInstance xmltv)
16     {
17     using (XMLTVLoader g = new XMLTVLoader(xml_file, xmltv)) { }
18     }
19 william 36 private XMLTVRuntimeInstance instance;
20 william 44 protected XMLTVLoader(string xml_file, XMLTVRuntimeInstance xmltv)
21 william 11 {
22 william 36 XMLTV_LOGGER.Log.Verbose.Debug.WriteLine("Creating Instance of XMLTVLoader");
23     //string _xmltv;
24     //if (!Internals.VerifyInstance<string>(xmltv, out _xmltv)) { return; }
25     //xmlfile = _xmltv;
26     //LoadXml();
27     instance = xmltv;
28     instance.XmlFile = new FileInfo(xml_file);
29 william 16 LoadXml();
30 william 11 }
31 william 36 //#region IXMLTV_LOADER
32     //public FileInfo XmlFile { get { return new FileInfo(xmlfile); } }
33     //public XDocument XmlDoc { get; private set; }
34     //#endregion
35 william 16
36     private void LoadXml()
37     {
38 william 36 XMLTV_LOGGER.Log.Info.WriteLine("Loading XMLTV File: {0}", instance.XmlFile.Name);
39 william 19 //XMLTV_LOGGER.Log.Warn.WriteLine("XML File Loading has not been implemented yet!");
40 william 21 try
41     {
42 william 36 instance.XmlDoc = XDocument.Load(instance.XmlFile.FullName);
43 william 21 }
44     catch (Exception ex)
45     {
46 william 36 XMLTV_LOGGER.Log.Error.WriteLine("Failed to load XMLTV File: {0}", instance.XmlFile.Name);
47 william 21 XMLTV_LOGGER.Log.Error.WriteLine(ex.GetBaseException().ToString());
48     }
49 william 16 }
50 william 44
51     public void Dispose()
52     {
53     //throw new NotImplementedException();
54     }
55 william 11 }
56     }