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


C# DtoOptions类代码示例

本文整理汇总了C#中DtoOptions的典型用法代码示例。如果您正苦于以下问题:C# DtoOptions类的具体用法?C# DtoOptions怎么用?C# DtoOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: GetBaseItemDto

        /// <summary>
        /// Converts a BaseItem to a DTOBaseItem
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="fields">The fields.</param>
        /// <param name="user">The user.</param>
        /// <param name="owner">The owner.</param>
        /// <returns>Task{DtoBaseItem}.</returns>
        /// <exception cref="System.ArgumentNullException">item</exception>
        public BaseItemDto GetBaseItemDto(BaseItem item, List<ItemFields> fields, User user = null, BaseItem owner = null)
        {
            var options = new DtoOptions
            {
                Fields = fields
            };

            return GetBaseItemDto(item, options, user, owner);
        }
开发者ID:loose-wardrobe,项目名称:Emby,代码行数:18,代码来源:DtoService.cs

示例2: GetPrograms

        public async Task<QueryResult<BaseItemDto>> GetPrograms(ProgramQuery query, DtoOptions options, CancellationToken cancellationToken)
        {
            var user = string.IsNullOrEmpty(query.UserId) ? null : _userManager.GetUserById(query.UserId);

            var topFolder = await GetInternalLiveTvFolder(cancellationToken).ConfigureAwait(false);

            if (query.SortBy.Length == 0)
            {
                // Unless something else was specified, order by start date to take advantage of a specialized index
                query.SortBy = new[] { ItemSortBy.StartDate };
            }

            var internalQuery = new InternalItemsQuery(user)
            {
                IncludeItemTypes = new[] { typeof(LiveTvProgram).Name },
                MinEndDate = query.MinEndDate,
                MinStartDate = query.MinStartDate,
                MaxEndDate = query.MaxEndDate,
                MaxStartDate = query.MaxStartDate,
                ChannelIds = query.ChannelIds,
                IsMovie = query.IsMovie,
                IsSports = query.IsSports,
                IsKids = query.IsKids,
                Genres = query.Genres,
                StartIndex = query.StartIndex,
                Limit = query.Limit,
                SortBy = query.SortBy,
                SortOrder = query.SortOrder ?? SortOrder.Ascending,
                EnableTotalRecordCount = query.EnableTotalRecordCount,
                TopParentIds = new[] { topFolder.Id.ToString("N") }
            };

            if (query.HasAired.HasValue)
            {
                if (query.HasAired.Value)
                {
                    internalQuery.MaxEndDate = DateTime.UtcNow;
                }
                else
                {
                    internalQuery.MinEndDate = DateTime.UtcNow;
                }
            }

            var queryResult = _libraryManager.QueryItems(internalQuery);

            RemoveFields(options);

            var returnArray = (await _dtoService.GetBaseItemDtos(queryResult.Items, options, user).ConfigureAwait(false)).ToArray();

            var result = new QueryResult<BaseItemDto>
            {
                Items = returnArray,
                TotalRecordCount = queryResult.TotalRecordCount
            };

            return result;
        }
开发者ID:7illusions,项目名称:Emby,代码行数:58,代码来源:LiveTvManager.cs

示例3: GetRecommendedPrograms

        public async Task<QueryResult<BaseItemDto>> GetRecommendedPrograms(RecommendedProgramQuery query, DtoOptions options, CancellationToken cancellationToken)
        {
            var internalResult = await GetRecommendedProgramsInternal(query, cancellationToken).ConfigureAwait(false);

            var user = _userManager.GetUserById(query.UserId);

            var returnArray = internalResult.Items
                .Select(i => new Tuple<BaseItemDto, string, string>(_dtoService.GetBaseItemDto(i, options, user), i.ServiceName, i.ExternalId))
                .ToArray();

            await AddRecordingInfo(returnArray, cancellationToken).ConfigureAwait(false);

            var result = new QueryResult<BaseItemDto>
            {
                Items = returnArray.Select(i => i.Item1).ToArray(),
                TotalRecordCount = internalResult.TotalRecordCount
            };

            return result;
        }
开发者ID:rezafouladian,项目名称:Emby,代码行数:20,代码来源:LiveTvManager.cs

示例4: GetChannels

        public async Task<QueryResult<ChannelInfoDto>> GetChannels(LiveTvChannelQuery query, DtoOptions options, CancellationToken cancellationToken)
        {
            var user = string.IsNullOrEmpty(query.UserId) ? null : _userManager.GetUserById(query.UserId);

            var internalResult = await GetInternalChannels(query, cancellationToken).ConfigureAwait(false);

            var returnList = new List<ChannelInfoDto>();

            var now = DateTime.UtcNow;

            var programs = query.AddCurrentProgram ? _libraryManager.QueryItems(new InternalItemsQuery
            {
                IncludeItemTypes = new[] { typeof(LiveTvProgram).Name },
                MaxStartDate = now,
                MinEndDate = now,
                ChannelIds = internalResult.Items.Select(i => i.Id.ToString("N")).ToArray()

            }).Items.Cast<LiveTvProgram>().OrderBy(i => i.StartDate).ToList() : new List<LiveTvProgram>();

            foreach (var channel in internalResult.Items)
            {
                var channelIdString = channel.Id.ToString("N");
                var currentProgram = programs.FirstOrDefault(i => string.Equals(i.ChannelId, channelIdString, StringComparison.OrdinalIgnoreCase));

                returnList.Add(_tvDtoService.GetChannelInfoDto(channel, options, currentProgram, user));
            }

            var result = new QueryResult<ChannelInfoDto>
            {
                Items = returnList.ToArray(),
                TotalRecordCount = internalResult.TotalRecordCount
            };

            return result;
        }
开发者ID:rezafouladian,项目名称:Emby,代码行数:35,代码来源:LiveTvManager.cs

示例5: GetRecording

        public async Task<BaseItemDto> GetRecording(string id, DtoOptions options, CancellationToken cancellationToken, User user = null)
        {
            var item = await GetInternalRecording(id, cancellationToken).ConfigureAwait(false);

            if (item == null)
            {
                return null;
            }

            return _dtoService.GetBaseItemDto((BaseItem)item, options, user);
        }
开发者ID:rezafouladian,项目名称:Emby,代码行数:11,代码来源:LiveTvManager.cs

示例6: RefreshChannelsInternal

        private async Task RefreshChannelsInternal(IProgress<double> progress, CancellationToken cancellationToken)
        {
            var numComplete = 0;
            double progressPerService = _services.Count == 0
                ? 0
                : 1 / _services.Count;

            var newChannelIdList = new List<Guid>();
            var newProgramIdList = new List<Guid>();

            foreach (var service in _services)
            {
                cancellationToken.ThrowIfCancellationRequested();

                _logger.Debug("Refreshing guide from {0}", service.Name);

                try
                {
                    var innerProgress = new ActionableProgress<double>();
                    innerProgress.RegisterAction(p => progress.Report(p * progressPerService));

                    var idList = await RefreshChannelsInternal(service, innerProgress, cancellationToken).ConfigureAwait(false);

                    newChannelIdList.AddRange(idList.Item1);
                    newProgramIdList.AddRange(idList.Item2);
                }
                catch (OperationCanceledException)
                {
                    throw;
                }
                catch (Exception ex)
                {
                    _logger.ErrorException("Error refreshing channels for service", ex);
                }

                numComplete++;
                double percent = numComplete;
                percent /= _services.Count;

                progress.Report(100 * percent);
            }

            await CleanDatabaseInternal(newChannelIdList, new[] { typeof(LiveTvChannel).Name }, progress, cancellationToken).ConfigureAwait(false);
            await CleanDatabaseInternal(newProgramIdList, new[] { typeof(LiveTvProgram).Name }, progress, cancellationToken).ConfigureAwait(false);

            var coreService = _services.OfType<EmbyTV.EmbyTV>().FirstOrDefault();

            if (coreService != null)
            {
                await coreService.RefreshSeriesTimers(cancellationToken, new Progress<double>()).ConfigureAwait(false);
            }

            // Load these now which will prefetch metadata
            var dtoOptions = new DtoOptions();
            dtoOptions.Fields.Remove(ItemFields.SyncInfo);
            await GetRecordings(new RecordingQuery(), dtoOptions, cancellationToken).ConfigureAwait(false);

            progress.Report(100);
        }
开发者ID:rezafouladian,项目名称:Emby,代码行数:59,代码来源:LiveTvManager.cs

示例7: GetBaseItemDtos

        public IEnumerable<BaseItemDto> GetBaseItemDtos(IEnumerable<BaseItem> items, DtoOptions options, User user = null, BaseItem owner = null)
        {
            var syncJobItems = GetSyncedItemProgress(options);
            var syncDictionary = GetSyncedItemProgressDictionary(syncJobItems);

            var list = new List<BaseItemDto>();

            foreach (var item in items)
            {
                var dto = GetBaseItemDtoInternal(item, options, syncDictionary, user, owner);

                var byName = item as IItemByName;

                if (byName != null)
                {
                    if (options.Fields.Contains(ItemFields.ItemCounts))
                    {
                        var itemFilter = byName.GetItemFilter();

                        var libraryItems = user != null ?
                           user.RootFolder.GetRecursiveChildren(user, itemFilter) :
                           _libraryManager.RootFolder.GetRecursiveChildren(itemFilter);

                        SetItemByNameInfo(item, dto, libraryItems.ToList(), user);
                    }
                }

                FillSyncInfo(dto, item, syncJobItems, options, user);

                list.Add(dto);
            }

            return list;
        }
开发者ID:loose-wardrobe,项目名称:Emby,代码行数:34,代码来源:DtoService.cs

示例8: GetItemByNameDto

        public BaseItemDto GetItemByNameDto(BaseItem item, DtoOptions options, List<BaseItem> taggedItems, User user = null)
        {
            var syncProgress = GetSyncedItemProgress(options);

            var dto = GetBaseItemDtoInternal(item, options, GetSyncedItemProgressDictionary(syncProgress), user);

            if (options.Fields.Contains(ItemFields.ItemCounts))
            {
                SetItemByNameInfo(item, dto, taggedItems, user);
            }

            FillSyncInfo(dto, item, options, user, syncProgress);

            return dto;
        }
开发者ID:loose-wardrobe,项目名称:Emby,代码行数:15,代码来源:DtoService.cs

示例9: GetRecordings

        public async Task<QueryResult<BaseItemDto>> GetRecordings(RecordingQuery query, DtoOptions options, CancellationToken cancellationToken)
        {
            var user = string.IsNullOrEmpty(query.UserId) ? null : _userManager.GetUserById(query.UserId);

            var internalResult = await GetInternalRecordings(query, cancellationToken).ConfigureAwait(false);

            var returnArray = _dtoService.GetBaseItemDtos(internalResult.Items, options, user).ToArray();

            return new QueryResult<BaseItemDto>
            {
                Items = returnArray,
                TotalRecordCount = internalResult.TotalRecordCount
            };
        }
开发者ID:paul-777,项目名称:Emby,代码行数:14,代码来源:LiveTvManager.cs

示例10: GetRecommendedProgramsInternal

        public async Task<QueryResult<LiveTvProgram>> GetRecommendedProgramsInternal(RecommendedProgramQuery query, DtoOptions options, CancellationToken cancellationToken)
        {
            var user = _userManager.GetUserById(query.UserId);

            var topFolder = await GetInternalLiveTvFolder(cancellationToken).ConfigureAwait(false);

            var internalQuery = new InternalItemsQuery(user)
            {
                IncludeItemTypes = new[] { typeof(LiveTvProgram).Name },
                IsAiring = query.IsAiring,
                IsNews = query.IsNews,
                IsMovie = query.IsMovie,
                IsSeries = query.IsSeries,
                IsSports = query.IsSports,
                IsKids = query.IsKids,
                EnableTotalRecordCount = query.EnableTotalRecordCount,
                SortBy = new[] { ItemSortBy.StartDate },
                TopParentIds = new[] { topFolder.Id.ToString("N") },
                DtoOptions = options
            };

            if (query.Limit.HasValue)
            {
                internalQuery.Limit = Math.Max(query.Limit.Value * 4, 200);
            }

            if (query.HasAired.HasValue)
            {
                if (query.HasAired.Value)
                {
                    internalQuery.MaxEndDate = DateTime.UtcNow;
                }
                else
                {
                    internalQuery.MinEndDate = DateTime.UtcNow;
                }
            }

            IEnumerable<LiveTvProgram> programs = _libraryManager.QueryItems(internalQuery).Items.Cast<LiveTvProgram>();

            var programList = programs.ToList();

            var factorChannelWatchCount = (query.IsAiring ?? false) || (query.IsKids ?? false) || (query.IsSports ?? false) || (query.IsMovie ?? false) || (query.IsNews ?? false) || (query.IsSeries ?? false);

            programs = programList.OrderBy(i => i.StartDate.Date)
                .ThenByDescending(i => GetRecommendationScore(i, user.Id, factorChannelWatchCount))
                .ThenBy(i => i.StartDate);

            if (query.Limit.HasValue)
            {
                programs = programs.Take(query.Limit.Value);
            }

            programList = programs.ToList();

            var returnArray = programList.ToArray();

            var result = new QueryResult<LiveTvProgram>
            {
                Items = returnArray,
                TotalRecordCount = returnArray.Length
            };

            return result;
        }
开发者ID:t-andre,项目名称:Emby,代码行数:65,代码来源:LiveTvManager.cs

示例11: GetPrograms

        public async Task<QueryResult<BaseItemDto>> GetPrograms(ProgramQuery query, DtoOptions options, CancellationToken cancellationToken)
        {
            var user = string.IsNullOrEmpty(query.UserId) ? null : _userManager.GetUserById(query.UserId);

            var topFolder = await GetInternalLiveTvFolder(cancellationToken).ConfigureAwait(false);

            if (query.SortBy.Length == 0)
            {
                // Unless something else was specified, order by start date to take advantage of a specialized index
                query.SortBy = new[] { ItemSortBy.StartDate };
            }

            var internalQuery = new InternalItemsQuery(user)
            {
                IncludeItemTypes = new[] { typeof(LiveTvProgram).Name },
                MinEndDate = query.MinEndDate,
                MinStartDate = query.MinStartDate,
                MaxEndDate = query.MaxEndDate,
                MaxStartDate = query.MaxStartDate,
                ChannelIds = query.ChannelIds,
                IsMovie = query.IsMovie,
                IsSeries = query.IsSeries,
                IsSports = query.IsSports,
                IsKids = query.IsKids,
                IsNews = query.IsNews,
                Genres = query.Genres,
                StartIndex = query.StartIndex,
                Limit = query.Limit,
                SortBy = query.SortBy,
                SortOrder = query.SortOrder ?? SortOrder.Ascending,
                EnableTotalRecordCount = query.EnableTotalRecordCount,
                TopParentIds = new[] { topFolder.Id.ToString("N") },
                Name = query.Name,
                DtoOptions = options
            };

            if (!string.IsNullOrWhiteSpace(query.SeriesTimerId))
            {
                var seriesTimers = await GetSeriesTimersInternal(new SeriesTimerQuery { }, cancellationToken).ConfigureAwait(false);
                var seriesTimer = seriesTimers.Items.FirstOrDefault(i => string.Equals(_tvDtoService.GetInternalSeriesTimerId(i.ServiceName, i.Id).ToString("N"), query.SeriesTimerId, StringComparison.OrdinalIgnoreCase));
                if (seriesTimer != null)
                {
                    internalQuery.ExternalSeriesId = seriesTimer.SeriesId;

                    if (string.IsNullOrWhiteSpace(seriesTimer.SeriesId))
                    {
                        // Better to return nothing than every program in the database
                        return new QueryResult<BaseItemDto>();
                    }
                }
                else
                {
                    // Better to return nothing than every program in the database
                    return new QueryResult<BaseItemDto>();
                }
            }

            if (query.HasAired.HasValue)
            {
                if (query.HasAired.Value)
                {
                    internalQuery.MaxEndDate = DateTime.UtcNow;
                }
                else
                {
                    internalQuery.MinEndDate = DateTime.UtcNow;
                }
            }

            var queryResult = _libraryManager.QueryItems(internalQuery);

            RemoveFields(options);

            var returnArray = (await _dtoService.GetBaseItemDtos(queryResult.Items, options, user).ConfigureAwait(false)).ToArray();

            var result = new QueryResult<BaseItemDto>
            {
                Items = returnArray,
                TotalRecordCount = queryResult.TotalRecordCount
            };

            return result;
        }
开发者ID:t-andre,项目名称:Emby,代码行数:83,代码来源:LiveTvManager.cs

示例12: RemoveFields

 private void RemoveFields(DtoOptions options)
 {
     options.Fields.Remove(ItemFields.CanDelete);
     options.Fields.Remove(ItemFields.CanDownload);
     options.Fields.Remove(ItemFields.DisplayPreferencesId);
     options.Fields.Remove(ItemFields.Etag);
 }
开发者ID:t-andre,项目名称:Emby,代码行数:7,代码来源:LiveTvManager.cs

示例13: AddChannelInfo

        public void AddChannelInfo(List<Tuple<BaseItemDto, LiveTvChannel>> tuples, DtoOptions options, User user)
        {
            var now = DateTime.UtcNow;

            var channelIds = tuples.Select(i => i.Item2.Id.ToString("N")).Distinct().ToArray();

            var programs = options.AddCurrentProgram ? _libraryManager.GetItemList(new InternalItemsQuery(user)
            {
                IncludeItemTypes = new[] { typeof(LiveTvProgram).Name },
                ChannelIds = channelIds,
                MaxStartDate = now,
                MinEndDate = now,
                Limit = channelIds.Length,
                SortBy = new[] { "StartDate" },
                TopParentIds = new[] { GetInternalLiveTvFolder(CancellationToken.None).Result.Id.ToString("N") }

            }).ToList() : new List<BaseItem>();

            RemoveFields(options);

            foreach (var tuple in tuples)
            {
                var dto = tuple.Item1;
                var channel = tuple.Item2;

                dto.Number = channel.Number;
                dto.ChannelNumber = channel.Number;
                dto.ChannelType = channel.ChannelType;
                dto.ServiceName = channel.ServiceName;

                if (options.Fields.Contains(ItemFields.MediaSources))
                {
                    dto.MediaSources = channel.GetMediaSources(true).ToList();
                }

                if (options.AddCurrentProgram)
                {
                    var channelIdString = channel.Id.ToString("N");
                    var currentProgram = programs.FirstOrDefault(i => string.Equals(i.ChannelId, channelIdString));

                    if (currentProgram != null)
                    {
                        dto.CurrentProgram = _dtoService.GetBaseItemDto(currentProgram, options, user);
                    }
                }
            }
        }
开发者ID:t-andre,项目名称:Emby,代码行数:47,代码来源:LiveTvManager.cs

示例14: GetRecordingSeries

        public async Task<QueryResult<BaseItemDto>> GetRecordingSeries(RecordingQuery query, DtoOptions options, CancellationToken cancellationToken)
        {
            var user = string.IsNullOrEmpty(query.UserId) ? null : _userManager.GetUserById(query.UserId);
            if (user != null && !IsLiveTvEnabled(user))
            {
                return new QueryResult<BaseItemDto>();
            }

            if (_services.Count > 1)
            {
                return new QueryResult<BaseItemDto>();
            }

            if (user == null || (query.IsInProgress ?? false))
            {
                return new QueryResult<BaseItemDto>();
            }

            var folders = EmbyTV.EmbyTV.Current.GetRecordingFolders()
                .SelectMany(i => i.Locations)
                .Distinct(StringComparer.OrdinalIgnoreCase)
                .Select(i => _libraryManager.FindByPath(i, true))
                .Where(i => i != null)
                .Where(i => i.IsVisibleStandalone(user))
                .ToList();

            if (folders.Count == 0)
            {
                return new QueryResult<BaseItemDto>();
            }

            var includeItemTypes = new List<string>();
            var excludeItemTypes = new List<string>();

            includeItemTypes.Add(typeof(Series).Name);

            var internalResult = _libraryManager.GetItemsResult(new InternalItemsQuery(user)
            {
                Recursive = true,
                AncestorIds = folders.Select(i => i.Id.ToString("N")).ToArray(),
                Limit = query.Limit,
                SortBy = new[] { ItemSortBy.DateCreated },
                SortOrder = SortOrder.Descending,
                EnableTotalRecordCount = query.EnableTotalRecordCount,
                IncludeItemTypes = includeItemTypes.ToArray(),
                ExcludeItemTypes = excludeItemTypes.ToArray()
            });

            RemoveFields(options);

            var returnArray = (await _dtoService.GetBaseItemDtos(internalResult.Items, options, user).ConfigureAwait(false)).ToArray();

            return new QueryResult<BaseItemDto>
            {
                Items = returnArray,
                TotalRecordCount = internalResult.TotalRecordCount
            };
        }
开发者ID:t-andre,项目名称:Emby,代码行数:58,代码来源:LiveTvManager.cs

示例15: GetEmbyRecordings

        private QueryResult<BaseItem> GetEmbyRecordings(RecordingQuery query, DtoOptions dtoOptions, User user)
        {
            if (user == null)
            {
                return new QueryResult<BaseItem>();
            }

            if ((query.IsInProgress ?? false))
            {
                return new QueryResult<BaseItem>();
            }

            var folders = EmbyTV.EmbyTV.Current.GetRecordingFolders()
                .SelectMany(i => i.Locations)
                .Distinct(StringComparer.OrdinalIgnoreCase)
                .Select(i => _libraryManager.FindByPath(i, true))
                .Where(i => i != null)
                .Where(i => i.IsVisibleStandalone(user))
                .ToList();

            if (folders.Count == 0)
            {
                return new QueryResult<BaseItem>();
            }

            var includeItemTypes = new List<string>();
            var excludeItemTypes = new List<string>();
            var genres = new List<string>();

            if (query.IsMovie.HasValue)
            {
                if (query.IsMovie.Value)
                {
                    includeItemTypes.Add(typeof(Movie).Name);
                }
                else
                {
                    excludeItemTypes.Add(typeof(Movie).Name);
                }
            }
            if (query.IsSeries.HasValue)
            {
                if (query.IsSeries.Value)
                {
                    includeItemTypes.Add(typeof(Episode).Name);
                }
                else
                {
                    excludeItemTypes.Add(typeof(Episode).Name);
                }
            }
            if (query.IsSports.HasValue)
            {
                if (query.IsSports.Value)
                {
                    genres.Add("Sports");
                }
            }
            if (query.IsKids.HasValue)
            {
                if (query.IsKids.Value)
                {
                    genres.Add("Kids");
                    genres.Add("Children");
                    genres.Add("Family");
                }
            }

            return _libraryManager.GetItemsResult(new InternalItemsQuery(user)
            {
                MediaTypes = new[] { MediaType.Video },
                Recursive = true,
                AncestorIds = folders.Select(i => i.Id.ToString("N")).ToArray(),
                IsFolder = false,
                ExcludeLocationTypes = new[] { LocationType.Virtual },
                Limit = query.Limit,
                SortBy = new[] { ItemSortBy.DateCreated },
                SortOrder = SortOrder.Descending,
                EnableTotalRecordCount = query.EnableTotalRecordCount,
                IncludeItemTypes = includeItemTypes.ToArray(),
                ExcludeItemTypes = excludeItemTypes.ToArray(),
                Genres = genres.ToArray(),
                DtoOptions = dtoOptions
            });
        }
开发者ID:t-andre,项目名称:Emby,代码行数:85,代码来源:LiveTvManager.cs


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