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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 128 by william, Wed Mar 13 13:45:05 2013 UTC revision 131 by william, Wed Mar 13 15:16:59 2013 UTC
# Line 14  namespace libxmltv.Core Line 14  namespace libxmltv.Core
14              public ChannelDefintionList() { }              public ChannelDefintionList() { }
15              public ChannelDefintionList(List<IChannelDefintion> collection) { collection.ForEach(s => this.Add(s)); }              public ChannelDefintionList(List<IChannelDefintion> collection) { collection.ForEach(s => this.Add(s)); }
16              #region IDataSourceSortable members              #region IDataSourceSortable members
17              public void Sort(ref object source, params string[] args)              public void Sort(ref object source, bool descending, params string[] args)
18              {              {
19              }              }
20              #endregion              #endregion
# Line 89  namespace libxmltv.Core Line 89  namespace libxmltv.Core
89              public ProgramDefinitionList() { }              public ProgramDefinitionList() { }
90              public ProgramDefinitionList(List<IProgramDefinition> collection) { collection.ForEach(s => this.Add(s)); }              public ProgramDefinitionList(List<IProgramDefinition> collection) { collection.ForEach(s => this.Add(s)); }
91              #region IDataSourceSortable members              #region IDataSourceSortable members
92              public void Sort(ref object source, params string[] args)              public void Sort(ref object source, bool descending, params string[] args)
93              {              {
94                  ProgramDefinitionList list = null;                  IProgramDefinitionList list = null;
95                    IOrderedEnumerable<IProgramDefinition> ordered = null;
96                  try                  try
97                  {                  {
98                      list = (ProgramDefinitionList)source;                      list = (ProgramDefinitionList)source;
99                        var col = args.First().ToString().ToLower();
                     var col = args[0].ToLower();  
100                      switch (col)                      switch (col)
101                      {                      {
102                          case "channelname": list =new ProgramDefinitionList( list.OrderBy(s => s.ChannelName).ToList()); break;                          case "channelname": ordered = descending ? list.OrderByDescending(s => s.ChannelName) : list.OrderBy(s => s.ChannelName); break;
103                          case "start": list = new ProgramDefinitionList( list.OrderBy(s => s.Start).ToList()); break;                          case "start": ordered = descending ? list.OrderByDescending(s => s.Start) : list.OrderBy(s => s.Start); break;
104                          case "stop": list = new ProgramDefinitionList( list.OrderBy(s => s.Stop).ToList()); break;                          case "stop": ordered = descending ? list.OrderByDescending(s => s.Stop) : list.OrderBy(s => s.Stop); break;
105                          case "description": list = new ProgramDefinitionList( list.OrderBy(s => s.Description).ToList()); break;                          case "description": ordered = descending ? list.OrderByDescending(s => s.Description) : list.OrderBy(s => s.Description); break;
106                          case "title": list = new ProgramDefinitionList( list.OrderBy(s => s.Title).ToList()); break;                          case "title": ordered = descending ? list.OrderByDescending(s => s.Title) : list.OrderBy(s => s.Title); break;
107                          case "subtitle": list = new ProgramDefinitionList(list.OrderBy(s => s.SubTitle).ToList()); break;                          case "subtitle": ordered = descending ? list.OrderByDescending(s => s.SubTitle) : list.OrderBy(s => s.SubTitle); break;
108                      }                      }
109                        //bool first = true;
110                        foreach (var arg in args.Skip(1))
111                        {
112                            col = arg.ToLower();
113                            switch (col)
114                            {
115                                case "channelname": ordered = descending ? ordered.ThenByDescending(s => s.ChannelName) : ordered.ThenBy(s => s.ChannelName); break;
116                                case "start": ordered = descending ? ordered.ThenByDescending(s => s.Start) : ordered.ThenBy(s => s.Start); break;
117                                case "stop": ordered = descending ? ordered.ThenByDescending(s => s.Stop) : ordered.ThenBy(s => s.Stop); break;
118                                case "description": ordered = descending ? ordered.ThenByDescending(s => s.Description) : ordered.ThenBy(s => s.Description); break;
119                                case "title": ordered = descending ? ordered.ThenByDescending(s => s.Title) : ordered.ThenBy(s => s.Title); break;
120                                case "subtitle": ordered = descending ? ordered.ThenByDescending(s => s.SubTitle) : ordered.ThenBy(s => s.SubTitle); break;
121                            }
122                        }
123                        list = new ProgramDefinitionList(ordered.ToList());
124                  }                  }
125                  catch (Exception ex) { throw ex; }                  catch (Exception ex) { throw ex; }
126                  if (list != null) { source = list; }                  if (list != null) { source = list; }

Legend:
Removed from v.128  
changed lines
  Added in v.131

  ViewVC Help
Powered by ViewVC 1.1.22