本文整理汇总了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;
}