本文整理汇总了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)
{
//.........这里部分代码省略.........
示例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);
}
示例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);
}
示例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);
}