本文整理汇总了C#中IHasImages.RemoveImage方法的典型用法代码示例。如果您正苦于以下问题:C# IHasImages.RemoveImage方法的具体用法?C# IHasImages.RemoveImage怎么用?C# IHasImages.RemoveImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IHasImages
的用法示例。
在下文中一共展示了IHasImages.RemoveImage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MergeImages
public bool MergeImages(IHasImages item, List<LocalImageInfo> images)
{
var changed = false;
foreach (var type in _singularImages)
{
var image = images.FirstOrDefault(i => i.Type == type);
if (image != null)
{
var currentImage = item.GetImageInfo(type, 0);
if (currentImage == null)
{
item.SetImagePath(type, image.FileInfo);
changed = true;
}
else if (!string.Equals(currentImage.Path, image.FileInfo.FullName, StringComparison.OrdinalIgnoreCase))
{
item.SetImagePath(type, image.FileInfo);
changed = true;
}
else
{
currentImage.DateModified = _fileSystem.GetLastWriteTimeUtc(image.FileInfo);
}
}
else
{
var existing = item.GetImageInfo(type, 0);
if (existing != null)
{
if (existing.IsLocalFile && !_fileSystem.FileExists(existing.Path))
{
item.RemoveImage(existing);
changed = true;
}
}
}
}
if (UpdateMultiImages(item, images, ImageType.Backdrop))
{
changed = true;
}
var hasScreenshots = item as IHasScreenshots;
if (hasScreenshots != null)
{
if (UpdateMultiImages(item, images, ImageType.Screenshot))
{
changed = true;
}
}
return changed;
}
示例2: ClearImages
private void ClearImages(IHasImages item, ImageType type)
{
var deleted = false;
var deletedImages = new List<ItemImageInfo>();
foreach (var image in item.GetImages(type).ToList())
{
if (!image.IsLocalFile)
{
deletedImages.Add(image);
continue;
}
// Delete the source file
var currentFile = new FileInfo(image.Path);
// Deletion will fail if the file is hidden so remove the attribute first
if (currentFile.Exists)
{
if ((currentFile.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden)
{
currentFile.Attributes &= ~FileAttributes.Hidden;
}
_fileSystem.DeleteFile(currentFile.FullName);
deleted = true;
}
}
foreach (var image in deletedImages)
{
item.RemoveImage(image);
}
if (deleted)
{
item.ValidateImages(new DirectoryService(_logger, _fileSystem));
}
}