9 |
namespace libxmltv.Core |
namespace libxmltv.Core |
10 |
{ |
{ |
11 |
[Serializable] |
[Serializable] |
12 |
internal class XMLTVSource : IXMLTVSource, IDisposable, ICloneable |
internal class XMLTVSource : XMLTVBase<XMLTVRuntimeInstance>, IXMLTVSource, IDisposable//, ICloneable |
13 |
{ |
{ |
14 |
|
|
15 |
private Dictionary<string, string> entries = new Dictionary<string, string>(); |
private Dictionary<string, string> entries = new Dictionary<string, string>(); |
16 |
internal static void CreateInstance(XMLTVRuntimeInstance xmltv) |
//internal static void CreateInstance(XMLTVRuntimeInstance xmltv) |
17 |
{ |
//{ |
18 |
using (XMLTVSource g = new XMLTVSource(xmltv)) |
// using (XMLTVSource g = new XMLTVSource(xmltv)) { g.instance.Source = (IXMLTVSource)g.Clone(); } |
19 |
{ |
//} |
20 |
g.instance.Source = (IXMLTVSource)g.Clone(); |
|
21 |
xmltv_logger.Info.WriteLine("Parsing Source: '{0}'", g.SourceName); |
//private XMLTVRuntimeInstance instance; |
22 |
} |
//protected XMLTVSource(string sourcename, string generatorname, string generatorurl) |
23 |
|
//{ |
24 |
|
// this.SourceName = sourcename; |
25 |
|
// this.GeneratorName = generatorname; |
26 |
|
// this.GeneratorUrl = generatorurl; |
27 |
|
//} |
28 |
|
public XMLTVSource() : base(null) |
29 |
|
{ |
30 |
|
this.SourceName = string.Empty; |
31 |
|
this.GeneratorName = string.Empty; |
32 |
|
this.GeneratorUrl = string.Empty; |
33 |
} |
} |
34 |
|
public XMLTVSource(XMLTVRuntimeInstance instance) : base(instance) |
|
private XMLTVRuntimeInstance instance; |
|
|
protected XMLTVSource(string sourcename, string generatorname, string generatorurl) |
|
|
{ |
|
|
this.SourceName = sourcename; |
|
|
this.GeneratorName = generatorname; |
|
|
this.GeneratorUrl = generatorurl; |
|
|
} |
|
|
protected XMLTVSource(XMLTVRuntimeInstance xmltv) |
|
35 |
{ |
{ |
36 |
xmltv_logger.Debug.WriteLine("Creating Instance of XMLTVSource"); |
xmltv_logger.Debug.WriteLine("Creating Instance of XMLTVSource"); |
|
//IXMLTV_PARSER _xmltv; |
|
|
//if (!Internals.VerifyInstance<IXMLTV_PARSER>(xmltv, out _xmltv)) { return; } |
|
|
//XMLTV_PARSER = _xmltv; |
|
|
instance = xmltv; |
|
37 |
Create(); |
Create(); |
38 |
|
xmltv_logger.Debug.WriteLine("Created Instance of XMLTVSource '{0}'", SourceName); |
39 |
} |
} |
40 |
|
|
41 |
#region IXMLTVSource |
#region IXMLTVSource |
47 |
|
|
48 |
private void Create() |
private void Create() |
49 |
{ |
{ |
50 |
var doc = XDocument.Parse(instance.XmlDoc); |
var doc = XDocument.Parse(this.GetInstance().XmlDoc); |
51 |
Debug.Assert(doc.Root.Name == XMLTVConstants.ROOT_ELEMENT, string.Format("Expected Root Element: '{0}' but read: '{1}'", XMLTVConstants.ROOT_ELEMENT, doc.Root.Name)); |
Debug.Assert(doc.Root.Name == XMLTVConstants.ROOT_ELEMENT, string.Format("Expected Root Element: '{0}' but read: '{1}'", XMLTVConstants.ROOT_ELEMENT, doc.Root.Name)); |
52 |
//xmltv_logger.Verbose.Debug.WriteLine("\tRoot: {0}", doc.Root.Name); |
//xmltv_logger.Verbose.Debug.WriteLine("\tRoot: {0}", doc.Root.Name); |
53 |
var attributes = doc.Root.Attributes().ToList(); |
var attributes = doc.Root.Attributes().ToList(); |
72 |
//throw new NotImplementedException(); |
//throw new NotImplementedException(); |
73 |
} |
} |
74 |
|
|
75 |
public object Clone() |
//public object Clone() |
76 |
{ |
//{ |
77 |
return new XMLTVSource(this.SourceName, this.GeneratorName, this.GeneratorUrl); |
// return new XMLTVSource(this.SourceName, this.GeneratorName, this.GeneratorUrl); |
78 |
} |
//} |
79 |
} |
} |
80 |
} |
} |