--- trunk/libxmltv/Core/DataSourceBindable.cs 2013/03/17 03:57:57 227 +++ trunk/libxmltv/Core/DataSourceBindable.cs 2013/04/17 21:55:30 254 @@ -24,6 +24,8 @@ { } #endregion + + } private class ChannelDefintion : IChannelDefintion { @@ -48,6 +50,28 @@ } return builder.ToString(); } + + private IXMLTVChannel _RawDataSource; public IXMLTVChannel RawDataSource { get { return _RawDataSource; } set { _RawDataSource = value; } } + + + public bool Equals(IChannelDefintion other) + { + return this.ToString() == other.ToString(); + } + public override bool Equals(object obj) + { + if (obj == null) { throw new ArgumentNullException("obj", "Object to compare cannot be null"); } + if (obj.GetType().IsAssignableFrom(typeof(IChannelDefintion))) + { + return this.Equals((IChannelDefintion)obj); + } + return base.Equals(obj); + } + public override int GetHashCode() + { + return this.ToString().GetHashCode(); + } + } //static private List known_columns; @@ -84,6 +108,7 @@ try { ChannelDefintion definition = new ChannelDefintion(); + definition.RawDataSource = t; definition.ChannelId = t.Id; definition.ChannelName = t.MetaData[XMLTVConstants.Channels.ChannelDisplayName].FirstOrDefault().Value.ToString(); xmltv_logger.Verbose.Debug.WriteLine(definition.ToString()); @@ -116,8 +141,8 @@ { case "channelnumber": ordered = descending ? list.OrderByDescending(s => s.ChannelNumber) : list.OrderBy(s => s.ChannelNumber); break; case "channelname": ordered = descending ? list.OrderByDescending(s => s.ChannelName) : list.OrderBy(s => s.ChannelName); break; - case "start": ordered = descending ? list.OrderByDescending(s => s.Start) : list.OrderBy(s => s.Start); break; - case "stop": ordered = descending ? list.OrderByDescending(s => s.Stop) : list.OrderBy(s => s.Stop); break; + case "start": ordered = descending ? list.OrderByDescending(s => DateTime.Parse(s.Start)) : list.OrderBy(s => DateTime.Parse(s.Start)); break; + case "stop": ordered = descending ? list.OrderByDescending(s => DateTime.Parse(s.Stop)) : list.OrderBy(s => DateTime.Parse(s.Stop)); break; 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; @@ -131,8 +156,8 @@ { case "channelnumber": ordered = descending ? ordered.ThenByDescending(s => s.ChannelNumber) : ordered.ThenBy(s => s.ChannelNumber); break; case "channelname": ordered = descending ? list.OrderByDescending(s => s.ChannelName) : list.OrderBy(s => s.ChannelName); break; - case "start": ordered = descending ? ordered.ThenByDescending(s => s.Start) : ordered.ThenBy(s => s.Start); break; - case "stop": ordered = descending ? ordered.ThenByDescending(s => s.Stop) : ordered.ThenBy(s => s.Stop); break; + case "start": ordered = descending ? ordered.ThenByDescending(s => DateTime.Parse(s.Start)) : ordered.ThenBy(s => DateTime.Parse(s.Start)); break; + case "stop": ordered = descending ? ordered.ThenByDescending(s => DateTime.Parse(s.Stop)) : ordered.ThenBy(s => DateTime.Parse(s.Stop)); break; 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; @@ -183,6 +208,7 @@ if (list != null) { source = list; } } #endregion + } public class ProgramDefintion : IProgramDefinition, IEquatable { @@ -221,6 +247,8 @@ return builder.ToString(); } + private IXMLTVProgram _RawDataSource; public IXMLTVProgram RawDataSource { get { return _RawDataSource; } set { _RawDataSource = value; } } + public bool Equals(IProgramDefinition other) { return this.ToString() == other.ToString(); @@ -264,6 +292,7 @@ try { ProgramDefintion definition = new ProgramDefintion(); + definition.RawDataSource = t; string ChannelId = t.MetaData[XMLTVConstants.Programs.ProgramChannelId].ToString(); //definition.ChannelId = ChannelId; @@ -313,7 +342,7 @@ catch (Exception ex) { throw ex; } } - list = new ProgramDefinitionList(list.OrderBy(s => s.Start).ToList()); + list = new ProgramDefinitionList(list.OrderBy(s => DateTime.Parse(s.Start)).ToList()); bindable = list; return bindable;