本文整理汇总了C#中IChannel.GetChannelItems方法的典型用法代码示例。如果您正苦于以下问题:C# IChannel.GetChannelItems方法的具体用法?C# IChannel.GetChannelItems怎么用?C# IChannel.GetChannelItems使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IChannel
的用法示例。
在下文中一共展示了IChannel.GetChannelItems方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetChannelItems
private async Task<ChannelItemResult> GetChannelItems(IChannel channel,
User user,
string folderId,
int? startIndex,
int? limit,
ChannelItemSortField? sortField,
bool sortDescending,
CancellationToken cancellationToken)
{
var userId = user.Id.ToString("N");
var cacheLength = CacheLength;
var cachePath = GetChannelDataCachePath(channel, userId, folderId, sortField, sortDescending);
try
{
if (!startIndex.HasValue && !limit.HasValue)
{
if (_fileSystem.GetLastWriteTimeUtc(cachePath).Add(cacheLength) > DateTime.UtcNow)
{
return _jsonSerializer.DeserializeFromFile<ChannelItemResult>(cachePath);
}
}
}
catch (FileNotFoundException)
{
}
catch (DirectoryNotFoundException)
{
}
await _resourcePool.WaitAsync(cancellationToken).ConfigureAwait(false);
try
{
try
{
if (!startIndex.HasValue && !limit.HasValue)
{
if (_fileSystem.GetLastWriteTimeUtc(cachePath).Add(cacheLength) > DateTime.UtcNow)
{
return _jsonSerializer.DeserializeFromFile<ChannelItemResult>(cachePath);
}
}
}
catch (FileNotFoundException)
{
}
catch (DirectoryNotFoundException)
{
}
var query = new InternalChannelItemQuery
{
UserId = userId,
StartIndex = startIndex,
Limit = limit,
SortBy = sortField,
SortDescending = sortDescending
};
if (!string.IsNullOrWhiteSpace(folderId))
{
var categoryItem = (IChannelItem)_libraryManager.GetItemById(new Guid(folderId));
query.FolderId = categoryItem.ExternalId;
}
var result = await channel.GetChannelItems(query, cancellationToken).ConfigureAwait(false);
if (!startIndex.HasValue && !limit.HasValue)
{
CacheResponse(result, cachePath);
}
return result;
}
finally
{
_resourcePool.Release();
}
}
示例2: GetChannelItems
private async Task<IEnumerable<ChannelItemInfo>> GetChannelItems(IChannel channel, User user, string categoryId, CancellationToken cancellationToken)
{
// TODO: Put some caching in here
var query = new InternalChannelItemQuery
{
User = user,
CategoryId = categoryId
};
var result = await channel.GetChannelItems(query, cancellationToken).ConfigureAwait(false);
return result.Items;
}