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


C# IHasImages.AllowsMultipleImages方法代码示例

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


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

示例1: SaveImage

        public async Task SaveImage(IHasImages item, Stream source, string mimeType, ImageType type, int? imageIndex, string internalCacheKey, CancellationToken cancellationToken)
        {
            if (string.IsNullOrEmpty(mimeType))
            {
                throw new ArgumentNullException("mimeType");
            }

            var saveLocally = item.SupportsLocalMetadata && item.IsSaveLocalMetadataEnabled() && !item.IsOwnedItem && !(item is Audio);

            if (item is User)
            {
                saveLocally = true;
            }

            if (type != ImageType.Primary && item is Episode)
            {
                saveLocally = false;
            }

            var locationType = item.LocationType;
            if (locationType == LocationType.Remote || locationType == LocationType.Virtual)
            {
                saveLocally = false;

                var season = item as Season;

                // If season is virtual under a physical series, save locally if using compatible convention
                if (season != null && _config.Configuration.ImageSavingConvention == ImageSavingConvention.Compatible)
                {
                    var series = season.Series;

                    if (series != null && series.SupportsLocalMetadata && series.IsSaveLocalMetadataEnabled())
                    {
                        saveLocally = true;
                    }
                }
            }
            if (!string.IsNullOrEmpty(internalCacheKey))
            {
                saveLocally = false;
            }

            if (!imageIndex.HasValue && item.AllowsMultipleImages(type))
            {
                imageIndex = item.GetImages(type).Count();
            }

            var index = imageIndex ?? 0;

            var paths = GetSavePaths(item, type, imageIndex, mimeType, saveLocally);

            var retryPaths = GetSavePaths(item, type, imageIndex, mimeType, false);

            // If there are more than one output paths, the stream will need to be seekable
            var memoryStream = new MemoryStream();
            using (source)
            {
                await source.CopyToAsync(memoryStream).ConfigureAwait(false);
            }

            source = memoryStream;

            var currentImage = GetCurrentImage(item, type, index);
            var savedPaths = new List<string>();

            using (source)
            {
                var currentPathIndex = 0;

                foreach (var path in paths)
                {
                    source.Position = 0;
                    string retryPath = null;
                    if (paths.Length == retryPaths.Length)
                    {
                        retryPath = retryPaths[currentPathIndex];
                    }
                    var savedPath = await SaveImageToLocation(source, path, retryPath, cancellationToken).ConfigureAwait(false);
                    savedPaths.Add(savedPath);
                    currentPathIndex++;
                }
            }

            // Set the path into the item
            SetImagePath(item, type, imageIndex, savedPaths[0]);

            // Delete the current path
            if (currentImage != null && currentImage.IsLocalFile && !savedPaths.Contains(currentImage.Path, StringComparer.OrdinalIgnoreCase))
            {
                var currentPath = currentImage.Path;

                _libraryMonitor.ReportFileSystemChangeBeginning(currentPath);

                try
                {
                    var currentFile = new FileInfo(currentPath);

                    // This will fail if the file is hidden
                    if (currentFile.Exists)
                    {
//.........这里部分代码省略.........
开发者ID:loose-wardrobe,项目名称:Emby,代码行数:101,代码来源:ImageSaver.cs

示例2: SaveImageStub

        private void SaveImageStub(IHasImages item, ImageType imageType, string url)
        {
            var newIndex = item.AllowsMultipleImages(imageType) ? item.GetImages(imageType).Count() : 0;

            item.SetImage(new ItemImageInfo
            {
                Path = url,
                Type = imageType

            }, newIndex);
        }
开发者ID:NickBolles,项目名称:Emby,代码行数:11,代码来源:ItemImageProvider.cs

示例3: SaveImageStub

        private void SaveImageStub(IHasImages item, ImageType imageType, IEnumerable<string> urls)
        {
            var newIndex = item.AllowsMultipleImages(imageType) ? item.GetImages(imageType).Count() : 0;

            SaveImageStub(item, imageType, urls, newIndex);
        }
开发者ID:t-andre,项目名称:Emby,代码行数:6,代码来源:ItemImageProvider.cs

示例4: SaveImageStub

        private void SaveImageStub(IHasImages item, ImageType imageType, string url)
        {
            var newIndex = item.AllowsMultipleImages(imageType) ? item.GetImages(imageType).Count() : 0;

            SaveImageStub(item, imageType, url, newIndex);
        }
开发者ID:RavenB,项目名称:Emby,代码行数:6,代码来源:ItemImageProvider.cs


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