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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

1 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 private XMLTVRuntimeInstance instance;
15 public XMLTVChannelCollection(XMLTVRuntimeInstance xmltv)
16 {
17 XMLTV_LOGGER.Log.Verbose.Debug.WriteLine("Creating Instance of XMLTVChannelCollection");
18 //IXMLTV_PARSER _xmltv;
19 //if (!Internals.VerifyInstance<IXMLTV_PARSER>(xmltv, out _xmltv)) { return; }
20 //XMLTV_PARSER = _xmltv;
21 instance = xmltv;
22 Create();
23 }
24
25 #region IXMLTVSource
26 //private IXMLTV_PARSER XMLTV_PARSER { get; set; }
27 public Dictionary<string, IXMLTVChannel> Collection
28 {
29 get { return entries; }
30 }
31 #endregion
32
33 private void Create()
34 {
35 var doc = instance.XmlDoc;
36
37 foreach (var c in doc.Descendants(XMLTVConstants.CHANNEL_ELEMENT))
38 {
39 Channel channel = new Channel(c);
40 entries.Add(channel.Id, channel);
41 }
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 [Serializable]
50 internal class Channel : IXMLTVChannel
51 {
52 public Channel()
53 {
54 Id = string.Empty;
55 Number = 0;
56 CallSign = string.Empty;
57 Name = string.Empty;
58 }
59 public Channel(XElement e)
60 : this()
61 {
62 // get the channel id
63 Id = e.Attribute(XMLTVConstants.Channels.ChannelId).Value;
64 var names = e.Descendants(XMLTVConstants.Channels.ChannelDisplayName).ToList();
65 Number = Convert.ToInt32(names[1].Value);
66 CallSign = names[2].Value;
67 Name = names[3].Value;
68 }
69 #region IXMLTVChannel members
70 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 #endregion
75 public override string ToString()
76 {
77 return string.Format("{0}: {1} {2} ({3})", Id,Number,Name, CallSign);
78 }
79 }
80 }
81

  ViewVC Help
Powered by ViewVC 1.1.22