/[xmltv_parser]/branches/linux/xmltv_parser/libxmltv/Core/XMLTVProgram.cs
ViewVC logotype

Contents of /branches/linux/xmltv_parser/libxmltv/Core/XMLTVProgram.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 74 - (show annotations) (download)
Sat Mar 9 11:06:39 2013 UTC (6 years, 6 months ago) by william
Original Path: trunk/libxmltv/Core/XMLTVProgram.cs
File size: 3202 byte(s)

1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using libxmltv.Interfaces;
6 using System.Xml.Linq;
7 using System.Reflection;
8
9 namespace libxmltv.Core
10 {
11 [Serializable]
12 internal class XMLTVProgram : XMLTVBase<XMLTVRuntimeInstance>, IXMLTVProgram
13 {
14 public XMLTVProgram() : base(null,XMLTVConstants.PROGRAM_ELEMENT)
15 {
16 Id = 0;
17 Start = new DateTime();
18 Stop = new DateTime();
19 Channel = new XMLTVChannel();
20 Title = string.Empty;
21 SubTitle = string.Empty;
22 Description = string.Empty;
23 }
24 public XMLTVProgram(XMLTVRuntimeInstance instance, XElement node)
25 : base(instance, XMLTVConstants.PROGRAM_ELEMENT)
26 {
27 xmltv_logger.Verbose.Debug.WriteLine("Creating Instance of XMLTVProgram");
28 // do the work here
29 xmltv_logger.Verbose.Debug.WriteLine("Created Instance of XMLTVProgram");
30 //UpdateInstance();
31 }
32 #region IXMLTVProgram members
33 public int Id { get; set; }
34 public DateTime Start { get; set; }
35 public DateTime Stop { get; set; }
36 public IXMLTVChannel Channel { get; set; }
37 public string Title { get; set; }
38 public string SubTitle { get; set; }
39 public string Description { get; set; }
40 #endregion
41 public override string ToString()
42 {
43 return string.Format("{0}: {1} - {2} ({3}) ['{4}' <==> '{5}']", Id, Title, SubTitle, Channel.ToString(), Start.ToString("yyyy/MM/dd hh:mm tt"), Stop.ToString("yyyy/MM/dd hh:mm tt"));
44 }
45
46 private void UpdateInstance()
47 {
48 bool found_field = false;
49 var instance_type = this.GetInstance().GetType();
50 var fields = instance_type.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
51 foreach (var field in fields)
52 {
53 if (field.FieldType == typeof(List<IXMLTVChannel>))
54 {
55 found_field = true;
56 try
57 {
58 xmltv_logger.Verbose.Debug.WriteLine("Updating instance with program information: {0}", this.ToString());
59 //field.SetValue(this.GetInstance(), new List<IXMLTVChannel>() { this });
60
61 var list = (List<IXMLTVProgram>)field.GetValue(this.GetInstance());
62 list.Add(this);
63 field.SetValue(this.GetInstance(), list);
64 break;
65 }
66 catch (Exception ex)
67 {
68 xmltv_logger.Verbose.Error.WriteLine("Unable to update instance with program information.");
69 xmltv_logger.Verbose.Error.WriteLine(ex.ToString());
70 }
71 }
72 }
73 if (!found_field)
74 {
75 xmltv_logger.Verbose.Error.WriteLine("Unable to update instance with program information.");
76 }
77 }
78 }
79 }

  ViewVC Help
Powered by ViewVC 1.1.22