57 |
private void InternalDictionaryTestOrThrow() |
private void InternalDictionaryTestOrThrow() |
58 |
{ |
{ |
59 |
if (Properties == null) { throw new NullReferenceException("Properties collection has not been initialized."); } |
if (Properties == null) { throw new NullReferenceException("Properties collection has not been initialized."); } |
60 |
if (Properties.Count == 0) { throw new IndexOutOfRangeException("Properties collection has 0 elements."); } |
//if (Properties.Count == 0) { throw new IndexOutOfRangeException("Properties collection has 0 elements."); } |
61 |
} |
} |
62 |
private void InternalProperyExistsOrThrow(string name) |
private void InternalProperyExistsOrThrow(string propertyname) |
63 |
{ |
{ |
64 |
InternalDictionaryTestOrThrow(); |
InternalDictionaryTestOrThrow(); |
65 |
if (!Properties.ContainsKey(name)) { throw new KeyNotFoundException(string.Format("Property '{0}' does not exist", name)); } |
//if (!ContainsProperty(propertyname)) { throw new KeyNotFoundException(string.Format("Property '{0}' does not exist.", propertyname)); } |
66 |
} |
} |
67 |
public object GetProperty(string name) |
|
68 |
|
public void RemoveProperty(string propertyname) |
69 |
|
{ |
70 |
|
if (ContainsProperty(propertyname)) |
71 |
|
{ |
72 |
|
Properties.Remove(propertyname); |
73 |
|
} |
74 |
|
else |
75 |
|
{ |
76 |
|
throw new ArgumentException(string.Format("Property '{0}' deos not exist", propertyname), propertyname); |
77 |
|
} |
78 |
|
} |
79 |
|
|
80 |
|
public void AddProperty(string propertyname) { AddProperty(propertyname, new object()); } |
81 |
|
public void AddProperty(string propertyname, object propertyvalue) |
82 |
|
{ |
83 |
|
if (!ContainsProperty(propertyname)) |
84 |
|
{ |
85 |
|
Properties.Add(propertyname, propertyvalue); |
86 |
|
} |
87 |
|
else |
88 |
|
{ |
89 |
|
SetProperty(propertyname, propertyvalue); |
90 |
|
} |
91 |
|
} |
92 |
|
public bool ContainsProperty(string propertyname) |
93 |
{ |
{ |
94 |
InternalProperyExistsOrThrow(name); |
return Properties.ContainsKey(propertyname); |
|
return Properties[name]; |
|
95 |
} |
} |
96 |
public void SetProperty(string name, object value) |
public object GetProperty(string propertyname) |
97 |
{ |
{ |
98 |
InternalProperyExistsOrThrow(name); |
InternalProperyExistsOrThrow(propertyname); |
99 |
Properties[name] = value; |
if (!ContainsProperty(propertyname)) { throw new KeyNotFoundException(string.Format("Property '{0}' does not exist.", propertyname)); } |
100 |
|
return Properties[propertyname]; |
101 |
|
} |
102 |
|
public void SetProperty(string propertyname, object propertyvalue) |
103 |
|
{ |
104 |
|
InternalProperyExistsOrThrow(propertyname); |
105 |
|
if (!ContainsProperty(propertyname)) { throw new KeyNotFoundException(string.Format("Property '{0}' does not exist.", propertyname)); } |
106 |
|
Properties[propertyname] = propertyvalue; |
107 |
} |
} |
108 |
#endregion |
#endregion |
109 |
public override string ToString() |
public override string ToString() |
111 |
return string.Format("{0}: {1} - {2} ({3}) ['{4}' <==> '{5}']", |
return string.Format("{0}: {1} - {2} ({3}) ['{4}' <==> '{5}']", |
112 |
GetProperty("Id").ToString(), |
GetProperty("Id").ToString(), |
113 |
GetProperty(XMLTVConstants.Programs.ProgramTitle).ToString(), |
GetProperty(XMLTVConstants.Programs.ProgramTitle).ToString(), |
114 |
GetProperty(XMLTVConstants.Programs.ProgramSubTitle), ToString(), |
GetProperty(XMLTVConstants.Programs.ProgramSubTitle).ToString(), |
115 |
GetProperty(XMLTVConstants.Programs.ProgramChannelId).ToString(), |
GetProperty(XMLTVConstants.Programs.ProgramChannelId).ToString(), |
116 |
((DateTime)GetProperty(XMLTVConstants.Programs.ProgramStart)).ToString("yyyy/MM/dd hh:mm tt"), |
((DateTime)GetProperty(XMLTVConstants.Programs.ProgramStart)).ToString("yyyy/MM/dd hh:mm tt"), |
117 |
((DateTime)GetProperty(XMLTVConstants.Programs.ProgramStop)).ToString("yyyy/MM/dd hh:mm tt")); |
((DateTime)GetProperty(XMLTVConstants.Programs.ProgramStop)).ToString("yyyy/MM/dd hh:mm tt")); |
196 |
|
|
197 |
//ParseExtraData(node); |
//ParseExtraData(node); |
198 |
|
|
199 |
var nodes = node.Elements().ToList(); |
var nodes = node.DescendantsAndSelf().ToList(); |
200 |
foreach (var sub_node in nodes) |
foreach (var sub_node in nodes) |
201 |
{ |
{ |
202 |
if (this.GetInstance().IsAborting) |
if (this.GetInstance().IsAborting) |
206 |
CreateHandlerForProgramMetaDataNode(sub_node); |
CreateHandlerForProgramMetaDataNode(sub_node); |
207 |
} |
} |
208 |
} |
} |
209 |
private DateTime ParseDate(string timeStamp) |
private static DateTime ParseDate(string timeStamp) |
210 |
{ |
{ |
211 |
DateTime dt = new DateTime(); |
DateTime dt = new DateTime(); |
212 |
try |
try |
219 |
|
|
220 |
private void CreateHandlerForProgramMetaDataNode(XElement node) |
private void CreateHandlerForProgramMetaDataNode(XElement node) |
221 |
{ |
{ |
222 |
|
|
223 |
Type t = this.GetType(); |
Type t = this.GetType(); |
224 |
Assembly asm = t.Assembly; |
Assembly asm = t.Assembly; |
225 |
var types = asm.GetTypes(); |
var types = asm.GetTypes(); |
271 |
string node_text = string.Format("{0}>", node_builder.ToString().TrimEnd(new char[] { ' ' })); |
string node_text = string.Format("{0}>", node_builder.ToString().TrimEnd(new char[] { ' ' })); |
272 |
xmltv_logger.Verbose.Warn.WriteLine("Ignoring unhandled extra meta-data: {0}", node_text); |
xmltv_logger.Verbose.Warn.WriteLine("Ignoring unhandled extra meta-data: {0}", node_text); |
273 |
} |
} |
274 |
raw_instance = Activator.CreateInstance(handler_type, flags, null, new object[] { this, node }, culture); |
else |
275 |
|
{ |
276 |
|
raw_instance = Activator.CreateInstance(handler_type, flags, null, new object[] { this, node }, culture); |
277 |
|
} |
278 |
} |
} |
279 |
|
|
280 |
|
|
285 |
public title() : base(null, XMLTVConstants.Programs.ProgramTitle) { } |
public title() : base(null, XMLTVConstants.Programs.ProgramTitle) { } |
286 |
public title(XMLTVProgram instance, XElement node) |
public title(XMLTVProgram instance, XElement node) |
287 |
: base(instance, XMLTVConstants.Programs.ProgramTitle) |
: base(instance, XMLTVConstants.Programs.ProgramTitle) |
288 |
{ |
{ |
289 |
|
if(node == null){throw new NullReferenceException("The node instance was null");} |
290 |
|
if (node.Value != null) |
291 |
|
{ |
292 |
|
instance.AddProperty(XMLTVConstants.Programs.ProgramTitle, node.Value); |
293 |
|
} |
294 |
} |
} |
295 |
} |
} |
296 |
#endregion |
#endregion |