本文整理汇总了C#中IHasImages.ValidateImages方法的典型用法代码示例。如果您正苦于以下问题:C# IHasImages.ValidateImages方法的具体用法?C# IHasImages.ValidateImages怎么用?C# IHasImages.ValidateImages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IHasImages
的用法示例。
在下文中一共展示了IHasImages.ValidateImages方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ValidateImages
public bool ValidateImages(IHasImages item, IEnumerable<IImageProvider> providers, IDirectoryService directoryService)
{
var hasChanges = item.ValidateImages(directoryService);
foreach (var provider in providers.OfType<ILocalImageFileProvider>())
{
var images = provider.GetImages(item, directoryService);
if (MergeImages(item, images))
{
hasChanges = true;
}
}
return hasChanges;
}
示例2: ClearImages
private void ClearImages(IHasImages item, ImageType type)
{
var deleted = false;
foreach (var image in item.GetImages(type).ToList())
{
// 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;
}
currentFile.Delete();
deleted = true;
}
}
if (deleted)
{
item.ValidateImages(new DirectoryService(_logger));
}
}
示例3: 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));
}
}