本文整理汇总了C#中IHasImages.SetImage方法的典型用法代码示例。如果您正苦于以下问题:C# IHasImages.SetImage方法的具体用法?C# IHasImages.SetImage怎么用?C# IHasImages.SetImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IHasImages
的用法示例。
在下文中一共展示了IHasImages.SetImage方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SaveImageStub
private void SaveImageStub(IHasImages item, ImageType imageType, IEnumerable<string> urls, int newIndex)
{
var path = string.Join("|", urls.Take(1).ToArray());
item.SetImage(new ItemImageInfo
{
Path = path,
Type = imageType
}, newIndex);
}
示例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: RefreshFromProvider
/// <summary>
/// Refreshes from provider.
/// </summary>
/// <param name="item">The item.</param>
/// <param name="provider">The provider.</param>
/// <param name="refreshOptions">The refresh options.</param>
/// <param name="savedOptions">The saved options.</param>
/// <param name="downloadedImages">The downloaded images.</param>
/// <param name="result">The result.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns>
private async Task RefreshFromProvider(IHasImages item,
IDynamicImageProvider provider,
ImageRefreshOptions refreshOptions,
MetadataOptions savedOptions,
ICollection<ImageType> downloadedImages,
RefreshResult result,
CancellationToken cancellationToken)
{
try
{
var images = provider.GetSupportedImages(item);
foreach (var imageType in images)
{
if (!IsEnabled(savedOptions, imageType, item)) continue;
if (!HasImage(item, imageType) || (refreshOptions.IsReplacingImage(imageType) && !downloadedImages.Contains(imageType)))
{
_logger.Debug("Running {0} for {1}", provider.GetType().Name, item.Path ?? item.Name);
var response = await provider.GetImage(item, imageType, cancellationToken).ConfigureAwait(false);
if (response.HasImage)
{
if (!string.IsNullOrEmpty(response.Path))
{
if (response.Protocol == MediaProtocol.Http)
{
_logger.Debug("Setting image url into item {0}", item.Id);
item.SetImage(new ItemImageInfo
{
Path = response.Path,
Type = imageType
}, 0);
}
else
{
var mimeType = MimeTypes.GetMimeType(response.Path);
var stream = _fileSystem.GetFileStream(response.Path, FileMode.Open, FileAccess.Read, FileShare.Read, true);
await _providerManager.SaveImage(item, stream, mimeType, imageType, null, cancellationToken).ConfigureAwait(false);
}
}
else
{
var mimeType = "image/" + response.Format.ToString().ToLower();
await _providerManager.SaveImage(item, response.Stream, mimeType, imageType, null, cancellationToken).ConfigureAwait(false);
}
downloadedImages.Add(imageType);
result.UpdateType = result.UpdateType | ItemUpdateType.ImageUpdate;
}
}
}
}
catch (OperationCanceledException)
{
throw;
}
catch (Exception ex)
{
result.ErrorMessage = ex.Message;
_logger.ErrorException("Error in {0}", ex, provider.Name);
}
}
示例4: SaveImageStub
private void SaveImageStub(IHasImages item, ImageType imageType, string url, int newIndex)
{
item.SetImage(new ItemImageInfo
{
Path = url,
Type = imageType
}, newIndex);
}