当前位置: 首页>>代码示例>>C#>>正文


C# Channel.ToList方法代码示例

本文整理汇总了C#中Channel.ToList方法的典型用法代码示例。如果您正苦于以下问题:C# Channel.ToList方法的具体用法?C# Channel.ToList怎么用?C# Channel.ToList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Channel的用法示例。


在下文中一共展示了Channel.ToList方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetChannelsWithFilter


//.........这里部分代码省略.........

                    if (filter.MinTotalVotes <= 0 && noTracksChannels != null)
                    {
                        channels = channels.Concat(noTracksChannels);
                    }
                    channels = channels.Distinct();
                }
                if (!filter.SortOption.Equals(""))
                {   // Apply specific sort order
                    if (filter.SortOption.Equals(filter.HitsAsc))
                    {
                        channels = from channel in channels orderby channel.Hits ascending select channel;
                    }
                    else if (filter.SortOption.Equals(filter.HitsDesc))
                    {
                        channels = from channel in channels orderby channel.Hits descending select channel;
                    }
                    else if (filter.SortOption.Equals(filter.NameAsc))
                    {
                        channels = from channel in channels orderby channel.Name ascending select channel;
                    }
                    else if (filter.SortOption.Equals(filter.NameDesc))
                    {
                        channels = from channel in channels orderby channel.Name descending select channel;
                    }
                    else if (filter.SortOption.Equals(filter.NumberOfCommentsAsc))
                    {
                        channels = from channel in channels orderby channel.Comments.Count ascending select channel;
                    }
                    else if (filter.SortOption.Equals(filter.NumberOfCommentsDesc))
                    {
                        channels = from channel in channels orderby channel.Comments.Count descending select channel;
                    }
                    else if (filter.SortOption.Equals(filter.SubscriptionsAsc))
                    {
                        channels = from channel in channels orderby channel.Subscribers.Count ascending select channel;
                    }
                    else if (filter.SortOption.Equals(filter.SubscriptionsDesc))
                    {
                        channels = from channel in channels orderby channel.Subscribers.Count descending select channel;
                    }
                    else if (filter.SortOption.Equals(filter.NumberOfVotesAsc))
                    {
                        channels = from channel in channels
                                   orderby (from track in channel.Tracks
                                            select track.UpVotes + track.DownVotes).Sum() ascending
                                   select channel;
                    }
                    else if (filter.SortOption.Equals(filter.NumberOfVotesDesc))
                    {
                        channels = from channel in channels
                                   orderby (from track in channel.Tracks
                                            select track.UpVotes + track.DownVotes).Sum() descending
                                   select channel;
                    }
                }
                else
                {
                    // Apply default sort order
                    channels = from channel in channels orderby channel.Name ascending select channel;
                }
                filteredChannels = channels.Any() == false ? new List<Channel>() : channels.ToList();
            }
            if (filter.StartIndex != -1 && filter.EndIndex != -1 && filter.StartIndex <= filter.EndIndex)
            {   // Only get the channels within the specified interval [filter.startIndex, ..., filter.endIndex-1]

                // The amount of channels
                int count;

                if (filter.StartIndex < -1)
                {   // If start index is negative, start from 0
                    count = filter.EndIndex;
                    filter.StartIndex = 0;
                }
                else
                {   // If both start and endindex are positive,
                    count = filter.EndIndex - filter.StartIndex;
                }

                if (filteredChannels.Count < filter.EndIndex) //Check if endindex is higher than the amount of channels found
                {
                    //Set endindex to the amount of channels found
                    filter.EndIndex = filteredChannels.Count;
                }
                if (filteredChannels.Count < filter.StartIndex) //Check if startindex is higher than the amount of channels found
                {
                    //Set startindex to the amount of channels found minus the amount of channels which should be retreived
                    filter.StartIndex = (filteredChannels.Count - count);
                    //Set endindex to the amount of channels found
                    filter.EndIndex = filteredChannels.Count;
                }

                //Create array to contain the result channels
                Channel[] result = new Channel[filter.EndIndex - filter.StartIndex];
                //Copy the channels to the result array
                filteredChannels.CopyTo(filter.StartIndex, result, 0, (filter.EndIndex - filter.StartIndex));
                return result.ToList();
            }
            return filteredChannels;
        }
开发者ID:markthor,项目名称:RentIt,代码行数:101,代码来源:DatabaseDao.cs


注:本文中的Channel.ToList方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。