/[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/16 17:56:55	181
+++ trunk/libxmltv/Core/DataSourceBindable.cs	2013/03/17 03:57:57	227
@@ -121,6 +121,7 @@
                         case "description": ordered = descending ? list.OrderByDescending(s => s.Description) : list.OrderBy(s => s.Description); break;
                         case "title": ordered = descending ? list.OrderByDescending(s => s.Title) : list.OrderBy(s => s.Title); break;
                         case "subtitle": ordered = descending ? list.OrderByDescending(s => s.SubTitle) : list.OrderBy(s => s.SubTitle); break;
+                        case "rating": ordered = descending ? list.OrderByDescending(s => s.Rating) : list.OrderBy(s => s.Rating); break;
                     }
                     //bool first = true;
                     foreach (var arg in args.Skip(1))
@@ -135,6 +136,7 @@
                             case "description": ordered = descending ? ordered.ThenByDescending(s => s.Description) : ordered.ThenBy(s => s.Description); break;
                             case "title": ordered = descending ? ordered.ThenByDescending(s => s.Title) : ordered.ThenBy(s => s.Title); break;
                             case "subtitle": ordered = descending ? ordered.ThenByDescending(s => s.SubTitle) : ordered.ThenBy(s => s.SubTitle); break;
+                            case "rating": ordered = descending ? ordered.ThenByDescending(s => s.Rating) : ordered.ThenBy(s => s.Rating); break;
                         }
                     }
                     list = new ProgramDefinitionList(ordered.ToList());
@@ -168,6 +170,7 @@
                         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;
+                        case "rating": ordered = list.ToList().FindAll(s => s.Rating.ToLower().Contains(filtertext)); break;
                     }                   
                     list = new ProgramDefinitionList(ordered.ToList());
                     if (list.Count == 0)
@@ -193,6 +196,7 @@
                 Description = string.Empty;
                 Title = string.Empty;
                 SubTitle = string.Empty;
+                Rating = string.Empty;
             }
             //public string ChannelId { get; internal set; }
             public int ChannelNumber { get; set; }
@@ -202,7 +206,7 @@
             public string Title { get; set; }
             public string SubTitle { get; set; }
             public string Description { get; set; }
-
+            public string Rating { get; set; }
             public override string ToString()
             {
                 StringBuilder builder = new StringBuilder();
@@ -290,6 +294,19 @@
                     definition.Title = t.MetaData[XMLTVConstants.Programs.ProgramTitle].ToString();
                     definition.SubTitle = t.MetaData[XMLTVConstants.Programs.ProgramSubTitle].ToString();
 
+                    
+                    var extras = t.GetExtraMetaData();
+                    foreach (var extra in extras)
+                    {
+                        if (extra.Name.ToLower() == "rating")
+                        {
+                            var root = extra.AsXElement();
+                            var child = root.Descendants("value").FirstOrDefault();
+                            if (child == null) { throw new NullReferenceException("Expected rating element to have a child elemented named: value"); }
+                            string value = child.Value;
+                            definition.Rating = value;
+                        }
+                    }
                     xmltv_logger.Verbose.Debug.WriteLine(definition.ToString());
                     list.Add(definition);
                 }

 

  ViewVC Help
Powered by ViewVC 1.1.22