/[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

--- trunk/libxmltv/Core/DataSourceBindable.cs	2013/03/13 15:16:59	131
+++ trunk/libxmltv/Core/DataSourceBindable.cs	2013/03/13 15:39:18	132
@@ -129,6 +129,33 @@
             #region IDataSourceFilterable members
             public void Filter(ref object source, params string[] args)
             {
+                IProgramDefinitionList list = null;
+                List<IProgramDefinition> ordered = null;
+                try
+                {
+                    list = (ProgramDefinitionList)source;
+                    //var col = args.First().ToString().ToLower();
+                    //var data = args.().ToString().ToLower();
+
+                    if (args.Count() != 2) { throw new ArgumentOutOfRangeException("args", "Excpected 2 aguments: columnname and filtertext"); }
+
+                    string columnname = args[0].ToLower();
+                    string filtertext = args[1].ToLower();
+
+                    switch (columnname)
+                    {
+                        case "channelname": ordered = list.ToList().FindAll(s => s.ChannelName.ToLower().Contains(filtertext)); break;
+                        case "start":
+                        case "stop":
+                            throw new ArgumentException("columnname", string.Format("Filtering for column: '{0}' has not been implemented", columnname));
+                        case "description": ordered = list.ToList().FindAll(s => s.Description.ToLower().Contains(filtertext)); break;
+                        case "title": ordered = list.ToList().FindAll(s => s.Title.ToLower().Contains(filtertext)); break;
+                        case "subtitle": ordered = list.ToList().FindAll(s => s.SubTitle.ToLower().Contains(filtertext)); break;
+                    }                   
+                    list = new ProgramDefinitionList(ordered.ToList());
+                }
+                catch (Exception ex) { throw ex; }
+                if (list != null) { source = list; }
             }
             #endregion
         }

 

  ViewVC Help
Powered by ViewVC 1.1.22