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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 122 - (hide annotations) (download)
Sun Mar 10 19:22:06 2013 UTC (6 years, 8 months ago) by william
File size: 4795 byte(s)

1 william 120 using System;
2     using System.Collections.Generic;
3     using System.Linq;
4     using System.Text;
5     using libxmltv.Interfaces;
6    
7     namespace libxmltv.Core
8     {
9     public class ChannelList : List<IXMLTVChannel>, IDataSourceBindable
10     {
11 william 122 private class ChannelDefintion
12 william 121 {
13 william 122 public ChannelDefintion()
14     {
15     ChannelId = string.Empty;
16     Name = string.Empty;
17     }
18     public string ChannelId { get; internal set; }
19     public string Name { get; internal set; }
20 william 121 }
21 william 122 //static private List<string> known_columns;
22     //static ChannelList()
23     //{
24     // known_columns = new List<string>();
25     // known_columns.Add("Id");
26     // known_columns.Add("Name");
27     //}
28 william 120 public ChannelList() { }
29    
30 william 122
31    
32 william 120 public object CreateBindableDataSource()
33     {
34     object bindable = new object();
35 william 122 List<ChannelDefintion> list = new List<ChannelDefintion>();
36    
37     foreach (var t in this)
38     {
39     try
40     {
41     ChannelDefintion definition = new ChannelDefintion();
42     definition.ChannelId = t.Id;
43     definition.Name = t.MetaData[XMLTVConstants.Channels.ChannelDisplayName].FirstOrDefault().Value.ToString();
44     list.Add(definition);
45     }
46     catch (Exception ex) { throw ex; }
47     }
48     bindable = list;
49 william 120 return bindable;
50     }
51     }
52     public class ProgramList : List<IXMLTVProgram>, IDataSourceBindable
53     {
54 william 122 private class ProgramDefintion
55 william 121 {
56 william 122 public ProgramDefintion()
57     {
58     ChannelId = string.Empty;
59     ChannelName = string.Empty;
60     Start = new DateTime();
61     Stop = new DateTime();
62     Description = string.Empty;
63     Title = string.Empty;
64     SubTitle = string.Empty;
65     }
66     public string ChannelId { get; internal set; }
67     public string ChannelName { get; internal set; }
68     public DateTime Start { get; internal set; }
69     public DateTime Stop { get; internal set; }
70     public string Description { get; internal set; }
71     public string Title { get; internal set; }
72     public string SubTitle { get; internal set; }
73 william 121 }
74 william 120 public ProgramList() { }
75    
76     public object CreateBindableDataSource()
77     {
78     object bindable = new object();
79 william 122 List<ProgramDefintion> list = new List<ProgramDefintion>();
80 william 121
81 william 122 foreach (var t in this)
82     {
83     try
84     {
85     ProgramDefintion definition = new ProgramDefintion();
86     definition.ChannelId = t.MetaData[XMLTVConstants.Programs.ProgramChannelId].ToString();
87 william 121
88 william 122 var channels = XMLTV.GetChannels();
89     if (channels != null)
90     {
91     var channel = channels.Find(p => p.Id == definition.ChannelId);
92     if (channel != null)
93     {
94     definition.ChannelName = channel.MetaData[XMLTVConstants.Channels.ChannelDisplayName].FirstOrDefault().Value.ToString();
95     }
96     else
97     {
98     definition.ChannelName = string.Empty;
99     }
100     }
101     else
102     {
103     definition.ChannelName = string.Empty;
104     }
105     definition.Start = (DateTime)t.MetaData[XMLTVConstants.Programs.ProgramStart];
106     definition.Stop = (DateTime)t.MetaData[XMLTVConstants.Programs.ProgramStop];
107     definition.Description = t.MetaData[XMLTVConstants.Programs.ProgramDescription].ToString();
108     definition.Title = t.MetaData[XMLTVConstants.Programs.ProgramTitle].ToString();
109     definition.SubTitle = t.MetaData[XMLTVConstants.Programs.ProgramSubTitle].ToString();
110     list.Add(definition);
111     }
112     catch (Exception ex) { throw ex; }
113     }
114     bindable = list;
115 william 120 return bindable;
116     }
117     }
118     public class ExtraList : List<IExtraMetaData>, IDataSourceBindable
119     {
120 william 121
121 william 120 public ExtraList() { }
122    
123     public object CreateBindableDataSource()
124     {
125     object bindable = new object();
126     return bindable;
127     }
128     }
129     }

  ViewVC Help
Powered by ViewVC 1.1.22