3 |
using System.Linq; |
using System.Linq; |
4 |
using System.Text; |
using System.Text; |
5 |
using libxmltv.Interfaces; |
using libxmltv.Interfaces; |
6 |
|
using System.Collections; |
7 |
|
|
8 |
namespace libxmltv.Core |
namespace libxmltv.Core |
9 |
{ |
{ |
10 |
public class ChannelList : List<IXMLTVChannel>, IDataSourceBindable |
public class ChannelList : List<IXMLTVChannel>, IDataSourceBindable |
11 |
{ |
{ |
12 |
private class ChannelDefintion : IDataSourceSortable, IDataSourceFilterable |
private class ChannelDefintionList : List<ChannelDefintion>, IDataSourceSortable, IDataSourceFilterable |
13 |
{ |
{ |
14 |
public ChannelDefintion() |
public ChannelDefintionList() { } |
15 |
{ |
public ChannelDefintionList(List<ChannelDefintion> collection) { collection.ForEach(s => this.Add(s)); } |
|
ChannelId = string.Empty; |
|
|
ChannelName = string.Empty; |
|
|
} |
|
|
public string ChannelId { get; internal set; } |
|
|
public string ChannelName { get; internal set; } |
|
|
|
|
16 |
#region IDataSourceSortable members |
#region IDataSourceSortable members |
17 |
public object Sort(object source, params string[] args) |
public void Sort(ref object source, params string[] args) |
18 |
{ |
{ |
|
return source; |
|
19 |
} |
} |
20 |
#endregion |
#endregion |
21 |
#region IDataSourceFilterable members |
#region IDataSourceFilterable members |
22 |
public object Filter(object source, params string[] args) |
public void Filter(ref object source, params string[] args) |
23 |
{ |
{ |
|
return source; |
|
24 |
} |
} |
25 |
#endregion |
#endregion |
26 |
} |
} |
27 |
|
private class ChannelDefintion |
28 |
|
{ |
29 |
|
public ChannelDefintion() |
30 |
|
{ |
31 |
|
ChannelId = string.Empty; |
32 |
|
ChannelName = string.Empty; |
33 |
|
} |
34 |
|
public string ChannelId { get; internal set; } |
35 |
|
public string ChannelName { get; internal set; } |
36 |
|
|
37 |
|
|
38 |
|
} |
39 |
//static private List<string> known_columns; |
//static private List<string> known_columns; |
40 |
//static ChannelList() |
//static ChannelList() |
41 |
//{ |
//{ |
50 |
public object CreateBindableDataSource() |
public object CreateBindableDataSource() |
51 |
{ |
{ |
52 |
object bindable = new object(); |
object bindable = new object(); |
53 |
List<ChannelDefintion> list = new List<ChannelDefintion>(); |
ChannelDefintionList list = new ChannelDefintionList(); |
54 |
|
|
55 |
foreach (var t in this) |
foreach (var t in this) |
56 |
{ |
{ |
63 |
} |
} |
64 |
catch (Exception ex) { throw ex; } |
catch (Exception ex) { throw ex; } |
65 |
} |
} |
66 |
list = list.OrderBy(s => s.ChannelName).ToList(); |
list = new ChannelDefintionList(list.OrderBy(s => s.ChannelName).ToList()); |
67 |
bindable = list; |
bindable = list; |
68 |
return bindable; |
return bindable; |
69 |
} |
} |
70 |
} |
} |
71 |
public class ProgramList : List<IXMLTVProgram>, IDataSourceBindable |
public class ProgramList : List<IXMLTVProgram>, IDataSourceBindable |
72 |
{ |
{ |
73 |
private class ProgramDefintion : IDataSourceSortable, IDataSourceFilterable |
private class ProgramDefinitionList : List<ProgramDefintion>, IDataSourceSortable, IDataSourceFilterable |
74 |
|
{ |
75 |
|
public ProgramDefinitionList() { } |
76 |
|
public ProgramDefinitionList(List<ProgramDefintion> collection) { collection.ForEach(s => this.Add(s)); } |
77 |
|
#region IDataSourceSortable members |
78 |
|
public void Sort(ref object source, params string[] args) |
79 |
|
{ |
80 |
|
ProgramDefinitionList list = null; |
81 |
|
try |
82 |
|
{ |
83 |
|
list = (ProgramDefinitionList)source; |
84 |
|
|
85 |
|
var col = args[0].ToLower(); |
86 |
|
switch (col) |
87 |
|
{ |
88 |
|
case "channelname": list =new ProgramDefinitionList( list.OrderBy(s => s.ChannelName).ToList()); break; |
89 |
|
case "start": list = new ProgramDefinitionList( list.OrderBy(s => s.Start).ToList()); break; |
90 |
|
case "stop": list = new ProgramDefinitionList( list.OrderBy(s => s.Stop).ToList()); break; |
91 |
|
case "description": list = new ProgramDefinitionList( list.OrderBy(s => s.Description).ToList()); break; |
92 |
|
case "title": list = new ProgramDefinitionList( list.OrderBy(s => s.Title).ToList()); break; |
93 |
|
case "subtitle": list = new ProgramDefinitionList(list.OrderBy(s => s.SubTitle).ToList()); break; |
94 |
|
} |
95 |
|
|
96 |
|
} |
97 |
|
catch (Exception ex) { throw ex; } |
98 |
|
if (list != null) { source = list; } |
99 |
|
} |
100 |
|
#endregion |
101 |
|
#region IDataSourceFilterable members |
102 |
|
public void Filter(ref object source, params string[] args) |
103 |
|
{ |
104 |
|
} |
105 |
|
#endregion |
106 |
|
} |
107 |
|
private class ProgramDefintion |
108 |
{ |
{ |
109 |
public ProgramDefintion() |
public ProgramDefintion() |
110 |
{ |
{ |
124 |
public string SubTitle { get; internal set; } |
public string SubTitle { get; internal set; } |
125 |
public string Description { get; internal set; } |
public string Description { get; internal set; } |
126 |
|
|
127 |
#region IDataSourceSortable members |
|
|
public object Sort(object source, params string[] args) |
|
|
{ |
|
|
return source; |
|
|
} |
|
|
#endregion |
|
|
#region IDataSourceFilterable members |
|
|
public object Filter(object source, params string[] args) |
|
|
{ |
|
|
return source; |
|
|
} |
|
|
#endregion |
|
128 |
} |
} |
129 |
public ProgramList() { } |
public ProgramList() { } |
130 |
|
|
131 |
public object CreateBindableDataSource() |
public object CreateBindableDataSource() |
132 |
{ |
{ |
133 |
object bindable = new object(); |
object bindable = new object(); |
134 |
List<ProgramDefintion> list = new List<ProgramDefintion>(); |
ProgramDefinitionList list = new ProgramDefinitionList(); |
135 |
|
|
136 |
foreach (var t in this) |
foreach (var t in this) |
137 |
{ |
{ |
168 |
catch (Exception ex) { throw ex; } |
catch (Exception ex) { throw ex; } |
169 |
} |
} |
170 |
|
|
171 |
list = list.OrderBy(s => s.Start).ToList(); |
list = new ProgramDefinitionList(list.OrderBy(s => s.Start).ToList()); |
172 |
|
|
173 |
bindable = list; |
bindable = list; |
174 |
return bindable; |
return bindable; |