Browse Source

Add [NotNull] and Check.NotNull for the ImageResizer/ImageCompressor

pull/16586/head
Salih 3 years ago
parent
commit
4bbdb4f6fa
  1. 15
      framework/src/Volo.Abp.Imaging.Abstractions/Volo/Abp/Imaging/ImageCompressor.cs
  2. 8
      framework/src/Volo.Abp.Imaging.Abstractions/Volo/Abp/Imaging/ImageResizer.cs

15
framework/src/Volo.Abp.Imaging.Abstractions/Volo/Abp/Imaging/ImageCompressor.cs

@ -2,6 +2,7 @@
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using JetBrains.Annotations;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Threading;
@ -19,8 +20,13 @@ public class ImageCompressor : IImageCompressor, ITransientDependency
CancellationTokenProvider = cancellationTokenProvider;
}
public virtual async Task<ImageCompressResult<Stream>> CompressAsync(Stream stream, string mimeType = null, CancellationToken cancellationToken = default)
public virtual async Task<ImageCompressResult<Stream>> CompressAsync(
[NotNull] Stream stream,
[CanBeNull] string mimeType = null,
CancellationToken cancellationToken = default)
{
Check.NotNull(stream, nameof(stream));
foreach (var imageCompressorContributor in ImageCompressorContributors)
{
var result = await imageCompressorContributor.TryCompressAsync(stream, mimeType, CancellationTokenProvider.FallbackToProvider(cancellationToken));
@ -36,8 +42,13 @@ public class ImageCompressor : IImageCompressor, ITransientDependency
return new ImageCompressResult<Stream>(stream, ImageProcessState.Unsupported);
}
public virtual async Task<ImageCompressResult<byte[]>> CompressAsync(byte[] bytes, string mimeType = null, CancellationToken cancellationToken = default)
public virtual async Task<ImageCompressResult<byte[]>> CompressAsync(
[NotNull] byte[] bytes,
[CanBeNull] string mimeType = null,
CancellationToken cancellationToken = default)
{
Check.NotNull(bytes, nameof(bytes));
foreach (var imageCompressorContributor in ImageCompressorContributors)
{
var result = await imageCompressorContributor.TryCompressAsync(bytes, mimeType, CancellationTokenProvider.FallbackToProvider(cancellationToken));

8
framework/src/Volo.Abp.Imaging.Abstractions/Volo/Abp/Imaging/ImageResizer.cs

@ -28,11 +28,13 @@ public class ImageResizer : IImageResizer, ITransientDependency
}
public virtual async Task<ImageResizeResult<Stream>> ResizeAsync(
Stream stream,
[NotNull] Stream stream,
ImageResizeArgs resizeArgs,
[CanBeNull] string mimeType = null,
CancellationToken cancellationToken = default)
{
Check.NotNull(stream, nameof(stream));
ChangeDefaultResizeMode(resizeArgs);
foreach (var imageResizerContributor in ImageResizerContributors)
@ -51,11 +53,13 @@ public class ImageResizer : IImageResizer, ITransientDependency
}
public virtual async Task<ImageResizeResult<byte[]>> ResizeAsync(
byte[] bytes,
[NotNull] byte[] bytes,
ImageResizeArgs resizeArgs,
[CanBeNull] string mimeType = null,
CancellationToken cancellationToken = default)
{
Check.NotNull(bytes, nameof(bytes));
ChangeDefaultResizeMode(resizeArgs);
foreach (var imageResizerContributor in ImageResizerContributors)

Loading…
Cancel
Save