3 |
using System.Linq; |
using System.Linq; |
4 |
using System.Text; |
using System.Text; |
5 |
using libxmltv.Interfaces; |
using libxmltv.Interfaces; |
6 |
|
using System.ComponentModel; |
7 |
|
|
8 |
namespace libxmltv.Core |
namespace libxmltv.Core |
9 |
{ |
{ |
10 |
internal class XMLTVRuntimeInstance : MarshalByRefObject, IXMLTVRuntimeInstance |
internal class XMLTVRuntimeInstance : MarshalByRefObject, IXMLTVRuntimeInstance |
11 |
{ |
{ |
12 |
public XMLTVRuntimeInstance(string xmlfile) { CreateInstance(xmlfile); } |
public XMLTVRuntimeInstance(string xmlfile) : this(xmlfile, null) { } |
13 |
private void CreateInstance(string xmlfile) { Instance = new XMLTVInstance(xmlfile, this); } |
public XMLTVRuntimeInstance(string xmlfile, EventHandler<CancelEventArgs> t) { CreateInstance(xmlfile,t); } |
14 |
|
private void CreateInstance(string xmlfile, EventHandler<CancelEventArgs> t) |
15 |
|
{ |
16 |
|
CancelEvent = t; |
17 |
|
using (Instance = new XMLTVInstance(xmlfile, this)) |
18 |
|
{ |
19 |
|
} |
20 |
|
} |
21 |
|
|
22 |
internal XMLTVInstance Instance { get; private set; } |
internal XMLTVInstance Instance { get; private set; } |
23 |
|
|
24 |
#region IXMLTV_LOADER members |
#region IXMLTV_LOADER members |
30 |
public Dictionary<string, IXMLTVChannel> Channels { get; set; } |
public Dictionary<string, IXMLTVChannel> Channels { get; set; } |
31 |
public Dictionary<int, IXMLTVProgram> Programs { get; set; } |
public Dictionary<int, IXMLTVProgram> Programs { get; set; } |
32 |
#endregion |
#endregion |
33 |
|
|
34 |
|
//public void Dispose() |
35 |
|
//{ |
36 |
|
// IsDisposing = true; |
37 |
|
// //throw new NotImplementedException(); |
38 |
|
//} |
39 |
|
//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 |
} |
} |
64 |
|
|
65 |
internal class XMLTVInstance |
internal class XMLTVInstance : IDisposable |
66 |
{ |
{ |
67 |
public XMLTVInstance(string xmlfile, XMLTVRuntimeInstance instance) |
public XMLTVInstance(string xmlfile, XMLTVRuntimeInstance instance) |
68 |
{ |
{ |
72 |
|
|
73 |
private void CreateLoader(string xml_file, XMLTVRuntimeInstance instance) |
private void CreateLoader(string xml_file, XMLTVRuntimeInstance instance) |
74 |
{ |
{ |
75 |
XMLTVLoader loader = new XMLTVLoader(xml_file, instance); |
//XMLTVLoader loader = new XMLTVLoader(xml_file, instance); |
76 |
|
XMLTVLoader.CreateInstance(xml_file, instance); |
77 |
} |
} |
78 |
private void CreateParser(XMLTVRuntimeInstance instance) |
private void CreateParser(XMLTVRuntimeInstance instance) |
79 |
{ |
{ |
80 |
XMLTVParser parser = new XMLTVParser(instance); |
//XMLTVParser parser = new XMLTVParser(instance); |
81 |
|
XMLTVParser.CreateInstance(instance); |
82 |
|
} |
83 |
|
|
84 |
|
public void Dispose() |
85 |
|
{ |
86 |
|
//throw new NotImplementedException(); |
87 |
} |
} |
88 |
} |
} |
89 |
} |
} |