/[xmltv_parser]/trunk/libxmltv/Core/XMLTVChannelCollection.cs
ViewVC logotype

Annotation of /trunk/libxmltv/Core/XMLTVChannelCollection.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 36 - (hide annotations) (download)
Fri Mar 8 02:13:59 2013 UTC (8 years, 2 months ago) by william
File size: 2680 byte(s)
+ use a MarshalByRefObject

1 william 26 using System;
2     using System.Collections.Generic;
3     using System.Linq;
4     using System.Text;
5     using libxmltv.Interfaces;
6     using System.Diagnostics;
7     using System.Xml.Linq;
8    
9     namespace libxmltv.Core
10     {
11     internal class XMLTVChannelCollection
12     {
13     private Dictionary<string, IXMLTVChannel> entries = new Dictionary<string, IXMLTVChannel>();
14 william 36 private XMLTVRuntimeInstance instance;
15     public XMLTVChannelCollection(XMLTVRuntimeInstance xmltv)
16 william 26 {
17     XMLTV_LOGGER.Log.Verbose.Debug.WriteLine("Creating Instance of XMLTVChannelCollection");
18 william 36 //IXMLTV_PARSER _xmltv;
19     //if (!Internals.VerifyInstance<IXMLTV_PARSER>(xmltv, out _xmltv)) { return; }
20     //XMLTV_PARSER = _xmltv;
21     instance = xmltv;
22 william 26 Create();
23     }
24    
25     #region IXMLTVSource
26 william 36 //private IXMLTV_PARSER XMLTV_PARSER { get; set; }
27 william 26 public Dictionary<string, IXMLTVChannel> Collection
28     {
29     get { return entries; }
30     }
31     #endregion
32    
33     private void Create()
34     {
35 william 36 var doc = instance.XmlDoc;
36 william 26
37 william 36 foreach (var c in doc.Descendants(XMLTVConstants.CHANNEL_ELEMENT))
38 william 26 {
39     Channel channel = new Channel(c);
40 william 28 entries.Add(channel.Id, channel);
41 william 26 }
42     }
43     public override string ToString()
44     {
45     //return string.Format("XmlTv Source: '{0}' (Generated by: '{1}') (support: '{2}')", SourceName, GeneratorName, GeneratorUrl);
46     return string.Empty;
47     }
48     }
49 william 31 [Serializable]
50 william 27 internal class Channel : IXMLTVChannel
51 william 26 {
52     public Channel()
53     {
54 william 28 Id = string.Empty;
55     Number = 0;
56     CallSign = string.Empty;
57     Name = string.Empty;
58 william 26 }
59 william 27 public Channel(XElement e)
60     : this()
61 william 26 {
62     // get the channel id
63 william 36 Id = e.Attribute(XMLTVConstants.Channels.ChannelId).Value;
64     var names = e.Descendants(XMLTVConstants.Channels.ChannelDisplayName).ToList();
65 william 28 Number = Convert.ToInt32(names[1].Value);
66     CallSign = names[2].Value;
67     Name = names[3].Value;
68 william 26 }
69     #region IXMLTVChannel members
70 william 28 public string Id { get; private set; }
71     public int Number { get; private set; }
72     public string CallSign { get; private set; }
73     public string Name { get; private set; }
74 william 26 #endregion
75 william 28 public override string ToString()
76     {
77     return string.Format("{0}: {1} {2} ({3})", Id,Number,Name, CallSign);
78     }
79 william 26 }
80     }
81    

  ViewVC Help
Powered by ViewVC 1.1.22