ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/xmltv_parser/trunk/libxmltv/Core/XMLTVChannel.cs
Revision: 27
Committed: Thu Mar 7 12:11:41 2013 UTC (10 years, 3 months ago) by william
File size: 2524 byte(s)
Log Message:
+ basic layout for Program entries

File Contents

# Content
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 public XMLTVChannelCollection(object xmltv)
15 {
16 XMLTV_LOGGER.Log.Verbose.Debug.WriteLine("Creating Instance of XMLTVChannelCollection");
17 IXMLTV_PARSER _xmltv;
18 if (!Internals.VerifyInstance<IXMLTV_PARSER>(xmltv, out _xmltv)) { return; }
19 XMLTV_PARSER = _xmltv;
20 Create();
21 }
22
23 #region IXMLTVSource
24 private IXMLTV_PARSER XMLTV_PARSER { get; set; }
25 public Dictionary<string, IXMLTVChannel> Collection
26 {
27 get { return entries; }
28 }
29 #endregion
30
31 private void Create()
32 {
33 var doc = XMLTV_PARSER.XMLTV_LOADER.XmlDoc;
34
35 foreach (var c in doc.Descendants(XMLTV_CONSTANTS.CHANNEL_ELEMENT))
36 {
37 Channel channel = new Channel(c);
38 entries.Add(channel.ChannelId, channel);
39 }
40 }
41 public override string ToString()
42 {
43 //return string.Format("XmlTv Source: '{0}' (Generated by: '{1}') (support: '{2}')", SourceName, GeneratorName, GeneratorUrl);
44 return string.Empty;
45 }
46 }
47
48 internal class Channel : IXMLTVChannel
49 {
50 public Channel()
51 {
52 ChannelId = string.Empty;
53 ChannelNumber = 0;
54 ChannelCallSign = string.Empty;
55 ChannelName = string.Empty;
56 }
57 public Channel(XElement e)
58 : this()
59 {
60 // get the channel id
61 ChannelId = e.Attribute(XMLTV_CONSTANTS.Channels.ChannelId).Value;
62 var names = e.Descendants(XMLTV_CONSTANTS.Channels.ChannelDisplayName).ToList();
63 ChannelNumber = Convert.ToInt32(names[1].Value);
64 ChannelCallSign = names[2].Value;
65 ChannelName = names[3].Value;
66 }
67 #region IXMLTVChannel members
68 public string ChannelId { get; private set; }
69 public int ChannelNumber { get; private set; }
70 public string ChannelCallSign { get; private set; }
71 public string ChannelName { get; private set; }
72 #endregion
73 }
74 }
75