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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 123 - (show annotations) (download)
Sun Mar 10 19:32:56 2013 UTC (6 years, 8 months ago) by william
File size: 4990 byte(s)

1 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 private class ChannelDefintion
12 {
13 public ChannelDefintion()
14 {
15 ChannelId = string.Empty;
16 ChannelName = string.Empty;
17 }
18 public string ChannelId { get; internal set; }
19 public string ChannelName { get; internal set; }
20 }
21 //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 public ChannelList() { }
29
30
31
32 public object CreateBindableDataSource()
33 {
34 object bindable = new object();
35 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.ChannelName = t.MetaData[XMLTVConstants.Channels.ChannelDisplayName].FirstOrDefault().Value.ToString();
44 list.Add(definition);
45 }
46 catch (Exception ex) { throw ex; }
47 }
48 list = list.OrderBy(s => s.ChannelName).ToList();
49 bindable = list;
50 return bindable;
51 }
52 }
53 public class ProgramList : List<IXMLTVProgram>, IDataSourceBindable
54 {
55 private class ProgramDefintion
56 {
57 public ProgramDefintion()
58 {
59 //ChannelId = string.Empty;
60 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 //public string ChannelId { get; internal set; }
68 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 public string Description { get; internal set; }
74 }
75 public ProgramList() { }
76
77 public object CreateBindableDataSource()
78 {
79 object bindable = new object();
80 List<ProgramDefintion> list = new List<ProgramDefintion>();
81
82 foreach (var t in this)
83 {
84 try
85 {
86 ProgramDefintion definition = new ProgramDefintion();
87 string ChannelId = t.MetaData[XMLTVConstants.Programs.ProgramChannelId].ToString();
88 //definition.ChannelId = ChannelId;
89
90 var channels = XMLTV.GetChannels();
91 if (channels != null)
92 {
93 var channel = channels.Find(p => p.Id == ChannelId);
94 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
117 list = list.OrderBy(s => s.Start).ToList();
118
119 bindable = list;
120 return bindable;
121 }
122 }
123 public class ExtraList : List<IExtraMetaData>, IDataSourceBindable
124 {
125
126 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