diff --git a/src/ImageSharp/Configuration.cs b/src/ImageSharp/Configuration.cs index ca83b0764e..3e021dda8d 100644 --- a/src/ImageSharp/Configuration.cs +++ b/src/ImageSharp/Configuration.cs @@ -122,25 +122,25 @@ public int StreamProcessingBufferSize public ReadOrigin ReadOrigin { get; set; } = ReadOrigin.Current; /// - /// Gets or sets the that is currently in use. + /// Gets or the that is currently in use. /// - public ImageFormatManager ImageFormatsManager { get; set; } = new ImageFormatManager(); + public ImageFormatManager ImageFormatsManager { get; private set; } = new ImageFormatManager(); /// - /// Gets or sets the that is currently in use. - /// Defaults to . + /// Gets or sets the that is currently in use. + /// Defaults to . /// /// Allocators are expensive, so it is strongly recommended to use only one busy instance per process. /// In case you need to customize it, you can ensure this by changing /// /// /// It's possible to reduce allocator footprint by assigning a custom instance created with - /// , but note that since the default pooling + /// , but note that since the default pooling /// allocators are expensive, it is strictly recommended to use a single process-wide allocator. /// You can ensure this by altering the allocator of , or by implementing custom application logic that /// manages allocator lifetime. /// - /// If an allocator has to be dropped for some reason, + /// If an allocator has to be dropped for some reason, /// shall be invoked after disposing all associated instances. /// public MemoryAllocator MemoryAllocator @@ -192,7 +192,7 @@ public void Configure(IConfigurationModule configuration) /// Creates a shallow copy of the . /// /// A new configuration instance. - public Configuration Clone() => new Configuration + public Configuration Clone() => new() { MaxDegreeOfParallelism = this.MaxDegreeOfParallelism, StreamProcessingBufferSize = this.StreamProcessingBufferSize, @@ -216,7 +216,7 @@ public void Configure(IConfigurationModule configuration) /// . /// /// The default configuration of . - internal static Configuration CreateDefaultInstance() => new Configuration( + internal static Configuration CreateDefaultInstance() => new( new PngConfigurationModule(), new JpegConfigurationModule(), new GifConfigurationModule(), diff --git a/src/ImageSharp/Formats/ImageFormatManager.cs b/src/ImageSharp/Formats/ImageFormatManager.cs index 2e18745925..f3fde403da 100644 --- a/src/ImageSharp/Formats/ImageFormatManager.cs +++ b/src/ImageSharp/Formats/ImageFormatManager.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. using System; @@ -17,27 +17,27 @@ public class ImageFormatManager /// Used for locking against as there is no ConcurrentSet type. /// /// - private static readonly object HashLock = new object(); + private static readonly object HashLock = new(); /// /// The list of supported keyed to mime types. /// - private readonly ConcurrentDictionary mimeTypeEncoders = new ConcurrentDictionary(); + private readonly ConcurrentDictionary mimeTypeEncoders = new(); /// /// The list of supported keyed to mime types. /// - private readonly ConcurrentDictionary mimeTypeDecoders = new ConcurrentDictionary(); + private readonly ConcurrentDictionary mimeTypeDecoders = new(); /// /// The list of supported s. /// - private readonly HashSet imageFormats = new HashSet(); + private readonly HashSet imageFormats = new(); /// /// The list of supported s. /// - private ConcurrentBag imageFormatDetectors = new ConcurrentBag(); + private ConcurrentBag imageFormatDetectors = new(); /// /// Initializes a new instance of the class. @@ -113,9 +113,7 @@ public IImageFormat FindFormatByFileExtension(string extension) /// The mime-type to discover /// The if found; otherwise null public IImageFormat FindFormatByMimeType(string mimeType) - { - return this.imageFormats.FirstOrDefault(x => x.MimeTypes.Contains(mimeType, StringComparer.OrdinalIgnoreCase)); - } + => this.imageFormats.FirstOrDefault(x => x.MimeTypes.Contains(mimeType, StringComparer.OrdinalIgnoreCase)); /// /// Sets a specific image encoder as the encoder for a specific image format. @@ -146,10 +144,7 @@ public void SetDecoder(IImageFormat imageFormat, IImageDecoder decoder) /// /// Removes all the registered image format detectors. /// - public void ClearImageFormatDetectors() - { - this.imageFormatDetectors = new ConcurrentBag(); - } + public void ClearImageFormatDetectors() => this.imageFormatDetectors = new(); /// /// Adds a new detector for detecting mime types. @@ -193,9 +188,6 @@ public IImageEncoder FindEncoder(IImageFormat format) /// /// Sets the max header size. /// - private void SetMaxHeaderSize() - { - this.MaxHeaderSize = this.imageFormatDetectors.Max(x => x.HeaderSize); - } + private void SetMaxHeaderSize() => this.MaxHeaderSize = this.imageFormatDetectors.Max(x => x.HeaderSize); } }