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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 46 - (hide annotations) (download)
Fri Mar 8 04:01:25 2013 UTC (7 years, 7 months ago) by william
File size: 1982 byte(s)
+ add support to cancel parseing when main form is closed

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 46 xmltv_logger.Log.Verbose.Debug.WriteLine("Creating Instance of XMLTVLoader");
23 william 36 //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 46 xmltv_logger.Log.Info.WriteLine("Loading XMLTV File: {0}", instance.XmlFile.Name);
39     //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 46 xmltv_logger.Log.Error.WriteLine("Failed to load XMLTV File: {0}", instance.XmlFile.Name);
47     xmltv_logger.Log.Error.WriteLine(ex.GetBaseException().ToString());
48 william 21 }
49 william 16 }
50 william 44
51     public void Dispose()
52     {
53     //throw new NotImplementedException();
54     }
55 william 11 }
56     }

  ViewVC Help
Powered by ViewVC 1.1.22