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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

1 william 36 using System;
2     using System.Collections.Generic;
3     using System.Linq;
4     using System.Text;
5     using libxmltv.Interfaces;
6 william 46 using System.ComponentModel;
7 william 36
8     namespace libxmltv.Core
9     {
10 william 45 internal class XMLTVRuntimeInstance : MarshalByRefObject, IXMLTVRuntimeInstance
11 william 36 {
12 william 46 public XMLTVRuntimeInstance(string xmlfile) : this(xmlfile, null) { }
13     public XMLTVRuntimeInstance(string xmlfile, EventHandler<CancelEventArgs> t) { CreateInstance(xmlfile,t); }
14     private void CreateInstance(string xmlfile, EventHandler<CancelEventArgs> t)
15 william 45 {
16 william 46 CancelEvent = t;
17 william 45 using (Instance = new XMLTVInstance(xmlfile, this))
18     {
19     }
20     }
21 william 46
22 william 36 internal XMLTVInstance Instance { get; private set; }
23    
24     #region IXMLTV_LOADER members
25     public System.IO.FileInfo XmlFile { get; set; }
26     public System.Xml.Linq.XDocument XmlDoc { get; set; }
27     #endregion
28     #region IXMLTV_PARSER Members
29     public IXMLTVSource Source { get; set; }
30     public Dictionary<string, IXMLTVChannel> Channels { get; set; }
31     public Dictionary<int, IXMLTVProgram> Programs { get; set; }
32     #endregion
33 william 44
34 william 45 //public void Dispose()
35     //{
36     // IsDisposing = true;
37     // //throw new NotImplementedException();
38     //}
39 william 46 //public bool IsDisposing { get; private set; }
40    
41    
42     private event EventHandler<CancelEventArgs> CancelEvent = null;
43    
44     public bool IsAborting
45     {
46     get
47     {
48     if (CancelEvent != null)
49     {
50     CancelEventArgs e = new CancelEventArgs();
51     CancelEvent.Invoke(this, e);
52     if (e.Cancel)
53     {
54     xmltv_logger.Log.Verbose.Debug.WriteLine("Detected Instance abort event...");
55     }
56     return e.Cancel;
57     }
58     return false;
59     }
60     }
61    
62    
63 william 36 }
64    
65 william 44 internal class XMLTVInstance : IDisposable
66 william 36 {
67     public XMLTVInstance(string xmlfile, XMLTVRuntimeInstance instance)
68     {
69     CreateLoader(xmlfile, instance);
70     CreateParser(instance);
71     }
72    
73     private void CreateLoader(string xml_file, XMLTVRuntimeInstance instance)
74     {
75 william 44 //XMLTVLoader loader = new XMLTVLoader(xml_file, instance);
76     XMLTVLoader.CreateInstance(xml_file, instance);
77 william 36 }
78     private void CreateParser(XMLTVRuntimeInstance instance)
79     {
80 william 44 //XMLTVParser parser = new XMLTVParser(instance);
81     XMLTVParser.CreateInstance(instance);
82 william 36 }
83 william 44
84     public void Dispose()
85     {
86     //throw new NotImplementedException();
87     }
88 william 36 }
89     }

  ViewVC Help
Powered by ViewVC 1.1.22