示例#1
0
 public Program(Channel channel, TimeRange timeRange, string title)
     : this()
 {
     Channel = channel;
     TimeRange = timeRange;
     Title = title;
     Attributes = new HashedSet<string>();
     Categories = new HashedSet<string>();
     Credits = new HashedSet<Credit>();
 }
示例#2
0
 public virtual bool Equals(Channel other)
 {
     if (ReferenceEquals(null, other)) return false;
     if (ReferenceEquals(this, other)) return true;
     return Equals(other.Id, Id);
 }
示例#3
0
        private void ExportChannel(XmlReader rdr, ISession session)
        {
            var root = GetElement(rdr);
            var channel = new Channel();

            channel.Id = root.AttrValue("id");
            ParseNames(root, channel);
            FindIcon(channel);

            using (var tx = session.BeginTransaction())
            {
                session.Save(channel);
                tx.Commit();
            }
            session.Clear();
        }
示例#4
0
 private void FindIcon(Channel channel)
 {
     if (_iconFiles == null)
     {
         var files = Directory.GetFiles(_iconFolderPath)
             .Select(p => new { path = p, name = Path.GetFileName(p) });
         _iconFiles = files.ToDictionary(x => x.name, x => x.path);
     }
     var iconPath = _iconFiles
         .Where(kv => kv.Key.StartsWith(channel.Number.ToString()))
         .Where(kv => !char.IsDigit(kv.Key[channel.Number.ToString().Length]))
         .Select(kv => kv.Value)
         .FirstOrDefault();
     channel.Icon = iconPath;
 }
示例#5
0
        private static void ParseNames(XElement root, Channel channel)
        {
            var names = root.Elements("display-name").Reverse();

            var number = (names.Where(name => name.Value.IsNumeric())
                              .FirstOrDefault() ?? new XElement("a")).Value;
            channel.Number = long.Parse(number);

            channel.LongName = names.Skip(1).Take(1).Single().Value;
            channel.ShortName = names.Skip(2).Take(1).Single().Value;
            if (channel.ShortName == channel.LongName)
                channel.LongName = names.Take(1).Single().Value;
        }