5 |
using libxmltv.Interfaces; |
using libxmltv.Interfaces; |
6 |
using System.Diagnostics; |
using System.Diagnostics; |
7 |
using System.Xml.Linq; |
using System.Xml.Linq; |
8 |
|
using System.Reflection; |
9 |
|
|
10 |
namespace libxmltv.Core |
namespace libxmltv.Core |
11 |
{ |
{ |
26 |
// this.GeneratorName = generatorname; |
// this.GeneratorName = generatorname; |
27 |
// this.GeneratorUrl = generatorurl; |
// this.GeneratorUrl = generatorurl; |
28 |
//} |
//} |
29 |
public XMLTVSource() : base(null) |
public XMLTVSource() |
30 |
|
: base(null, XMLTVConstants.ROOT_ELEMENT) |
31 |
{ |
{ |
32 |
this.SourceName = string.Empty; |
this.SourceName = string.Empty; |
33 |
this.GeneratorName = string.Empty; |
this.GeneratorName = string.Empty; |
34 |
this.GeneratorUrl = string.Empty; |
this.GeneratorUrl = string.Empty; |
35 |
} |
} |
36 |
public XMLTVSource(XMLTVRuntimeInstance instance) : base(instance) |
public XMLTVSource(XMLTVRuntimeInstance instance) : base(instance, XMLTVConstants.ROOT_ELEMENT) |
37 |
{ |
{ |
38 |
xmltv_logger.Debug.WriteLine("Creating Instance of XMLTVSource"); |
xmltv_logger.Debug.WriteLine("Creating Instance of XMLTVSource"); |
39 |
Create(); |
Create(); |
40 |
xmltv_logger.Debug.WriteLine("Created Instance of XMLTVSource '{0}'", SourceName); |
xmltv_logger.Debug.WriteLine("Created Instance of XMLTVSource '{0}'", SourceName); |
41 |
|
UpdateInstance(); |
42 |
} |
} |
43 |
|
|
44 |
|
private void UpdateInstance() |
45 |
|
{ |
46 |
|
bool found_field = false; |
47 |
|
var instance_type = this.GetInstance().GetType(); |
48 |
|
var fields = instance_type.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); |
49 |
|
foreach (var field in fields) |
50 |
|
{ |
51 |
|
if (field.FieldType == typeof(List<IXMLTVSource>)) |
52 |
|
{ |
53 |
|
found_field = true; |
54 |
|
try |
55 |
|
{ |
56 |
|
xmltv_logger.Debug.WriteLine("Updating instance with source information."); |
57 |
|
field.SetValue(this.GetInstance(), new List<IXMLTVSource>() { this }); |
58 |
|
break; |
59 |
|
} |
60 |
|
catch (Exception ex) |
61 |
|
{ |
62 |
|
xmltv_logger.Error.WriteLine("Unable to update instance with source information."); |
63 |
|
xmltv_logger.Error.WriteLine(ex.ToString()); |
64 |
|
} |
65 |
|
} |
66 |
|
} |
67 |
|
if (!found_field) |
68 |
|
{ |
69 |
|
xmltv_logger.Error.WriteLine("Unable to update instance with source information."); |
70 |
|
} |
71 |
|
} |
72 |
|
|
73 |
#region IXMLTVSource |
#region IXMLTVSource |
74 |
//private IXMLTV_PARSER XMLTV_PARSER { get; set; } |
//private IXMLTV_PARSER XMLTV_PARSER { get; set; } |
75 |
public string SourceName { get; private set; } |
public string SourceName { get; private set; } |