/[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 123 - (hide annotations) (download)
Sun Mar 10 19:32:56 2013 UTC (6 years, 8 months ago) by william
File size: 4990 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 william 123 ChannelName = string.Empty;
17 william 122 }
18     public string ChannelId { get; internal set; }
19 william 123 public string ChannelName { 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 william 123 definition.ChannelName = t.MetaData[XMLTVConstants.Channels.ChannelDisplayName].FirstOrDefault().Value.ToString();
44 william 122 list.Add(definition);
45     }
46     catch (Exception ex) { throw ex; }
47     }
48 william 123 list = list.OrderBy(s => s.ChannelName).ToList();
49 william 122 bindable = list;
50 william 120 return bindable;
51     }
52     }
53     public class ProgramList : List<IXMLTVProgram>, IDataSourceBindable
54     {
55 william 122 private class ProgramDefintion
56 william 121 {
57 william 122 public ProgramDefintion()
58     {
59 william 123 //ChannelId = string.Empty;
60 william 122 ChannelName = string.Empty;
61     Start = new DateTime();
62     Stop = new DateTime();
63     Description = string.Empty;
64     Title = string.Empty;
65     SubTitle = string.Empty;
66     }
67 william 123 //public string ChannelId { get; internal set; }
68 william 122 public string ChannelName { get; internal set; }
69     public DateTime Start { get; internal set; }
70     public DateTime Stop { get; internal set; }
71     public string Title { get; internal set; }
72     public string SubTitle { get; internal set; }
73 william 123 public string Description { get; internal set; }
74 william 121 }
75 william 120 public ProgramList() { }
76    
77     public object CreateBindableDataSource()
78     {
79     object bindable = new object();
80 william 122 List<ProgramDefintion> list = new List<ProgramDefintion>();
81 william 121
82 william 122 foreach (var t in this)
83     {
84     try
85     {
86     ProgramDefintion definition = new ProgramDefintion();
87 william 123 string ChannelId = t.MetaData[XMLTVConstants.Programs.ProgramChannelId].ToString();
88     //definition.ChannelId = ChannelId;
89 william 121
90 william 122 var channels = XMLTV.GetChannels();
91     if (channels != null)
92     {
93 william 123 var channel = channels.Find(p => p.Id == ChannelId);
94 william 122 if (channel != null)
95     {
96     definition.ChannelName = channel.MetaData[XMLTVConstants.Channels.ChannelDisplayName].FirstOrDefault().Value.ToString();
97     }
98     else
99     {
100     definition.ChannelName = string.Empty;
101     }
102     }
103     else
104     {
105     definition.ChannelName = string.Empty;
106     }
107     definition.Start = (DateTime)t.MetaData[XMLTVConstants.Programs.ProgramStart];
108     definition.Stop = (DateTime)t.MetaData[XMLTVConstants.Programs.ProgramStop];
109     definition.Description = t.MetaData[XMLTVConstants.Programs.ProgramDescription].ToString();
110     definition.Title = t.MetaData[XMLTVConstants.Programs.ProgramTitle].ToString();
111     definition.SubTitle = t.MetaData[XMLTVConstants.Programs.ProgramSubTitle].ToString();
112     list.Add(definition);
113     }
114     catch (Exception ex) { throw ex; }
115     }
116 william 123
117     list = list.OrderBy(s => s.Start).ToList();
118    
119 william 122 bindable = list;
120 william 120 return bindable;
121     }
122     }
123     public class ExtraList : List<IExtraMetaData>, IDataSourceBindable
124     {
125 william 121
126 william 120 public ExtraList() { }
127    
128     public object CreateBindableDataSource()
129     {
130     object bindable = new object();
131     return bindable;
132     }
133     }
134     }

  ViewVC Help
Powered by ViewVC 1.1.22