// // Copyright (c) James Jackson-South and contributors. // Licensed under the Apache License, Version 2.0. // namespace ImageProcessorCore { using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Threading.Tasks; using Formats; /// /// Provides initialization code which allows extending the library. /// public class Bootstrapper { /// /// A new instance Initializes a new instance of the class. /// with lazy initialization. /// private static readonly Lazy Lazy = new Lazy(() => new Bootstrapper()); /// /// The default list of supported /// private readonly List imageFormats; /// /// Prevents a default instance of the class from being created. /// private Bootstrapper() { this.imageFormats = new List { new BmpFormat(), new JpegFormat(), new PngFormat(), new GifFormat() }; } /// /// Gets the current bootstrapper instance. /// public static Bootstrapper Instance = Lazy.Value; /// /// Gets the collection of supported /// public IReadOnlyCollection ImageFormats => new ReadOnlyCollection(this.imageFormats); /// /// Gets or sets the global parallel options for processing tasks in parallel. /// public ParallelOptions ParallelOptions { get; set; } = new ParallelOptions { MaxDegreeOfParallelism = Environment.ProcessorCount }; /// /// Adds a new to the collection of supported image formats. /// /// The new format to add. public void AddImageFormat(IImageFormat format) { this.imageFormats.Add(format); } } }