Browse Source

Rename Bootstrapper to Configuration

af/merge-core
James Jackson-South 10 years ago
parent
commit
ef60a6237e
  1. 1
      Settings.StyleCop
  2. 14
      src/ImageSharp/Configuration.cs
  3. 2
      src/ImageSharp/Formats/IImageFormat.cs
  4. 6
      src/ImageSharp/Formats/Jpg/JpegDecoderCore.cs
  5. 24
      src/ImageSharp/Image.cs
  6. 22
      src/ImageSharp/Image/ImageBase{TColor}.cs
  7. 12
      src/ImageSharp/Image/ImageFrame{TColor}.cs
  8. 38
      src/ImageSharp/Image/Image{TColor}.cs
  9. 4
      src/ImageSharp/Image/PixelAccessor{TColor}.cs
  10. 8
      src/ImageSharp/ImageFrame.cs
  11. 2
      src/ImageSharp/ImageProcessor.cs
  12. 2
      src/ImageSharp/Quantizers/Quantize.cs
  13. 2
      tests/ImageSharp.Benchmarks/Image/CopyPixels.cs
  14. 26
      tests/ImageSharp.Tests/ConfigurationTests.cs
  15. 8
      tests/ImageSharp.Tests/TestFile.cs
  16. 2
      tests/ImageSharp.Tests/TestUtilities/ImagingTestCaseUtility.cs

1
Settings.StyleCop

@ -39,7 +39,6 @@
<Value>desensitivity</Value> <Value>desensitivity</Value>
<Value>premultiplied</Value> <Value>premultiplied</Value>
<Value>endianness</Value> <Value>endianness</Value>
<Value>bootstrapper</Value>
<Value>thresholding</Value> <Value>thresholding</Value>
</CollectionProperty> </CollectionProperty>
</GlobalSettings> </GlobalSettings>

14
src/ImageSharp/Bootstrapper.cs → src/ImageSharp/Configuration.cs

@ -1,4 +1,4 @@
// <copyright file="Bootstrapper.cs" company="James Jackson-South"> // <copyright file="Configuration.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors. // Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright> // </copyright>
@ -16,15 +16,15 @@ namespace ImageSharp
/// <summary> /// <summary>
/// Provides initialization code which allows extending the library. /// Provides initialization code which allows extending the library.
/// </summary> /// </summary>
public class Bootstrapper public class Configuration
{ {
/// <summary> /// <summary>
/// A lazily initialized bootstrapper default instance. /// A lazily initialized configuration default instance.
/// </summary> /// </summary>
private static readonly Lazy<Bootstrapper> Lazy = new Lazy<Bootstrapper>(() => new Bootstrapper()); private static readonly Lazy<Configuration> Lazy = new Lazy<Configuration>(() => new Configuration());
/// <summary> /// <summary>
/// An object that can be used to synchronize access to the <see cref="Bootstrapper"/>. /// An object that can be used to synchronize access to the <see cref="Configuration"/>.
/// </summary> /// </summary>
private static readonly object SyncRoot = new object(); private static readonly object SyncRoot = new object();
@ -34,9 +34,9 @@ namespace ImageSharp
private readonly List<IImageFormat> imageFormatsList = new List<IImageFormat>(); private readonly List<IImageFormat> imageFormatsList = new List<IImageFormat>();
/// <summary> /// <summary>
/// Gets the default <see cref="Bootstrapper"/> instance. /// Gets the default <see cref="Configuration"/> instance.
/// </summary> /// </summary>
public static Bootstrapper Default { get; } = Lazy.Value; public static Configuration Default { get; } = Lazy.Value;
/// <summary> /// <summary>
/// Gets the collection of supported <see cref="IImageFormat"/> /// Gets the collection of supported <see cref="IImageFormat"/>

2
src/ImageSharp/Formats/IImageFormat.cs

@ -9,7 +9,7 @@ namespace ImageSharp.Formats
/// <summary> /// <summary>
/// Encapsulates a supported image format, providing means to encode and decode an image. /// Encapsulates a supported image format, providing means to encode and decode an image.
/// Individual formats implements in this interface must be registered in the <see cref="Bootstrapper"/> /// Individual formats implements in this interface must be registered in the <see cref="Configuration"/>
/// </summary> /// </summary>
public interface IImageFormat public interface IImageFormat
{ {

6
src/ImageSharp/Formats/Jpg/JpegDecoderCore.cs

@ -687,7 +687,7 @@ namespace ImageSharp.Formats
Parallel.For( Parallel.For(
0, 0,
height, height,
image.Bootstrapper.ParallelOptions, image.Configuration.ParallelOptions,
y => y =>
{ {
int yoff = this.grayImage.GetRowOffset(y); int yoff = this.grayImage.GetRowOffset(y);
@ -723,7 +723,7 @@ namespace ImageSharp.Formats
Parallel.For( Parallel.For(
0, 0,
height, height,
image.Bootstrapper.ParallelOptions, image.Configuration.ParallelOptions,
y => y =>
{ {
// TODO: Simplify + optimize + share duplicate code across converter methods // TODO: Simplify + optimize + share duplicate code across converter methods
@ -764,7 +764,7 @@ namespace ImageSharp.Formats
Parallel.For( Parallel.For(
0, 0,
height, height,
image.Bootstrapper.ParallelOptions, image.Configuration.ParallelOptions,
y => y =>
{ {
// TODO: Simplify + optimize + share duplicate code across converter methods // TODO: Simplify + optimize + share duplicate code across converter methods

24
src/ImageSharp/Image.cs

@ -21,11 +21,11 @@ namespace ImageSharp
/// </summary> /// </summary>
/// <param name="width">The width of the image in pixels.</param> /// <param name="width">The width of the image in pixels.</param>
/// <param name="height">The height of the image in pixels.</param> /// <param name="height">The height of the image in pixels.</param>
/// <param name="bootstrapper"> /// <param name="configuration">
/// The bootstrapper providing initialization code which allows extending the library. /// The configuration providing initialization code which allows extending the library.
/// </param> /// </param>
public Image(int width, int height, Bootstrapper bootstrapper = null) public Image(int width, int height, Configuration configuration = null)
: base(width, height, bootstrapper) : base(width, height, configuration)
{ {
} }
@ -35,12 +35,12 @@ namespace ImageSharp
/// <param name="stream"> /// <param name="stream">
/// The stream containing image information. /// The stream containing image information.
/// </param> /// </param>
/// <param name="bootstrapper"> /// <param name="configuration">
/// The bootstrapper providing initialization code which allows extending the library. /// The configuration providing initialization code which allows extending the library.
/// </param> /// </param>
/// <exception cref="System.ArgumentNullException">Thrown if the <paramref name="stream"/> is null.</exception> /// <exception cref="System.ArgumentNullException">Thrown if the <paramref name="stream"/> is null.</exception>
public Image(Stream stream, Bootstrapper bootstrapper = null) public Image(Stream stream, Configuration configuration = null)
: base(stream, bootstrapper) : base(stream, configuration)
{ {
} }
@ -50,12 +50,12 @@ namespace ImageSharp
/// <param name="bytes"> /// <param name="bytes">
/// The byte array containing image information. /// The byte array containing image information.
/// </param> /// </param>
/// <param name="bootstrapper"> /// <param name="configuration">
/// The bootstrapper providing initialization code which allows extending the library. /// The configuration providing initialization code which allows extending the library.
/// </param> /// </param>
/// <exception cref="System.ArgumentNullException">Thrown if the <paramref name="bytes"/> is null.</exception> /// <exception cref="System.ArgumentNullException">Thrown if the <paramref name="bytes"/> is null.</exception>
public Image(byte[] bytes, Bootstrapper bootstrapper = null) public Image(byte[] bytes, Configuration configuration = null)
: base(bytes, bootstrapper) : base(bytes, configuration)
{ {
} }

22
src/ImageSharp/Image/ImageBase{TColor}.cs

@ -25,12 +25,12 @@ namespace ImageSharp
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="ImageBase{TColor}"/> class. /// Initializes a new instance of the <see cref="ImageBase{TColor}"/> class.
/// </summary> /// </summary>
/// <param name="bootstrapper"> /// <param name="configuration">
/// The bootstrapper providing initialization code which allows extending the library. /// The configuration providing initialization code which allows extending the library.
/// </param> /// </param>
protected ImageBase(Bootstrapper bootstrapper = null) protected ImageBase(Configuration configuration = null)
{ {
this.Bootstrapper = bootstrapper ?? Bootstrapper.Default; this.Configuration = configuration ?? Configuration.Default;
} }
/// <summary> /// <summary>
@ -38,15 +38,15 @@ namespace ImageSharp
/// </summary> /// </summary>
/// <param name="width">The width of the image in pixels.</param> /// <param name="width">The width of the image in pixels.</param>
/// <param name="height">The height of the image in pixels.</param> /// <param name="height">The height of the image in pixels.</param>
/// <param name="bootstrapper"> /// <param name="configuration">
/// The bootstrapper providing initialization code which allows extending the library. /// The configuration providing initialization code which allows extending the library.
/// </param> /// </param>
/// <exception cref="System.ArgumentOutOfRangeException"> /// <exception cref="System.ArgumentOutOfRangeException">
/// Thrown if either <paramref name="width"/> or <paramref name="height"/> are less than or equal to 0. /// Thrown if either <paramref name="width"/> or <paramref name="height"/> are less than or equal to 0.
/// </exception> /// </exception>
protected ImageBase(int width, int height, Bootstrapper bootstrapper = null) protected ImageBase(int width, int height, Configuration configuration = null)
{ {
this.Bootstrapper = bootstrapper ?? Bootstrapper.Default; this.Configuration = configuration ?? Configuration.Default;
this.InitPixels(width, height); this.InitPixels(width, height);
} }
@ -104,9 +104,9 @@ namespace ImageSharp
public int FrameDelay { get; set; } public int FrameDelay { get; set; }
/// <summary> /// <summary>
/// Gets the bootstrapper providing initialization code which allows extending the library. /// Gets the configuration providing initialization code which allows extending the library.
/// </summary> /// </summary>
public Bootstrapper Bootstrapper { get; private set; } public Configuration Configuration { get; private set; }
/// <inheritdoc/> /// <inheritdoc/>
public void InitPixels(int width, int height) public void InitPixels(int width, int height)
@ -170,7 +170,7 @@ namespace ImageSharp
/// </param> /// </param>
protected void CopyProperties(ImageBase<TColor> other) protected void CopyProperties(ImageBase<TColor> other)
{ {
this.Bootstrapper = other.Bootstrapper; this.Configuration = other.Configuration;
this.Quality = other.Quality; this.Quality = other.Quality;
this.FrameDelay = other.FrameDelay; this.FrameDelay = other.FrameDelay;
} }

12
src/ImageSharp/Image/ImageFrame{TColor}.cs

@ -21,11 +21,11 @@ namespace ImageSharp
/// </summary> /// </summary>
/// <param name="width">The width of the image in pixels.</param> /// <param name="width">The width of the image in pixels.</param>
/// <param name="height">The height of the image in pixels.</param> /// <param name="height">The height of the image in pixels.</param>
/// <param name="bootstrapper"> /// <param name="configuration">
/// The bootstrapper providing initialization code which allows extending the library. /// The configuration providing initialization code which allows extending the library.
/// </param> /// </param>
public ImageFrame(int width, int height, Bootstrapper bootstrapper = null) public ImageFrame(int width, int height, Configuration configuration = null)
: base(width, height, bootstrapper) : base(width, height, configuration)
{ {
} }
@ -55,7 +55,7 @@ namespace ImageSharp
{ {
scaleFunc = PackedPixelConverterHelper.ComputeScaleFunction<TColor, TColor2>(scaleFunc); scaleFunc = PackedPixelConverterHelper.ComputeScaleFunction<TColor, TColor2>(scaleFunc);
ImageFrame<TColor2> target = new ImageFrame<TColor2>(this.Width, this.Height, this.Bootstrapper) ImageFrame<TColor2> target = new ImageFrame<TColor2>(this.Width, this.Height, this.Configuration)
{ {
Quality = this.Quality, Quality = this.Quality,
FrameDelay = this.FrameDelay FrameDelay = this.FrameDelay
@ -67,7 +67,7 @@ namespace ImageSharp
Parallel.For( Parallel.For(
0, 0,
target.Height, target.Height,
this.Bootstrapper.ParallelOptions, this.Configuration.ParallelOptions,
y => y =>
{ {
for (int x = 0; x < target.Width; x++) for (int x = 0; x < target.Width; x++)

38
src/ImageSharp/Image/Image{TColor}.cs

@ -43,13 +43,13 @@ namespace ImageSharp
/// </summary> /// </summary>
/// <param name="width">The width of the image in pixels.</param> /// <param name="width">The width of the image in pixels.</param>
/// <param name="height">The height of the image in pixels.</param> /// <param name="height">The height of the image in pixels.</param>
/// <param name="bootstrapper"> /// <param name="configuration">
/// The bootstrapper providing initialization code which allows extending the library. /// The configuration providing initialization code which allows extending the library.
/// </param> /// </param>
public Image(int width, int height, Bootstrapper bootstrapper = null) public Image(int width, int height, Configuration configuration = null)
: base(width, height, bootstrapper) : base(width, height, configuration)
{ {
this.CurrentImageFormat = this.Bootstrapper.ImageFormats.First(); this.CurrentImageFormat = this.Configuration.ImageFormats.First();
} }
/// <summary> /// <summary>
@ -58,12 +58,12 @@ namespace ImageSharp
/// <param name="stream"> /// <param name="stream">
/// The stream containing image information. /// The stream containing image information.
/// </param> /// </param>
/// <param name="bootstrapper"> /// <param name="configuration">
/// The bootstrapper providing initialization code which allows extending the library. /// The configuration providing initialization code which allows extending the library.
/// </param> /// </param>
/// <exception cref="System.ArgumentNullException">Thrown if the <paramref name="stream"/> is null.</exception> /// <exception cref="System.ArgumentNullException">Thrown if the <paramref name="stream"/> is null.</exception>
public Image(Stream stream, Bootstrapper bootstrapper = null) public Image(Stream stream, Configuration configuration = null)
: base(bootstrapper) : base(configuration)
{ {
Guard.NotNull(stream, nameof(stream)); Guard.NotNull(stream, nameof(stream));
this.Load(stream); this.Load(stream);
@ -75,12 +75,12 @@ namespace ImageSharp
/// <param name="bytes"> /// <param name="bytes">
/// The byte array containing image information. /// The byte array containing image information.
/// </param> /// </param>
/// <param name="bootstrapper"> /// <param name="configuration">
/// The bootstrapper providing initialization code which allows extending the library. /// The configuration providing initialization code which allows extending the library.
/// </param> /// </param>
/// <exception cref="System.ArgumentNullException">Thrown if the <paramref name="bytes"/> is null.</exception> /// <exception cref="System.ArgumentNullException">Thrown if the <paramref name="bytes"/> is null.</exception>
public Image(byte[] bytes, Bootstrapper bootstrapper = null) public Image(byte[] bytes, Configuration configuration = null)
: base(bootstrapper) : base(configuration)
{ {
Guard.NotNull(bytes, nameof(bytes)); Guard.NotNull(bytes, nameof(bytes));
@ -296,7 +296,7 @@ namespace ImageSharp
{ {
scaleFunc = PackedPixelConverterHelper.ComputeScaleFunction<TColor, TColor2>(scaleFunc); scaleFunc = PackedPixelConverterHelper.ComputeScaleFunction<TColor, TColor2>(scaleFunc);
Image<TColor2> target = new Image<TColor2>(this.Width, this.Height, this.Bootstrapper) Image<TColor2> target = new Image<TColor2>(this.Width, this.Height, this.Configuration)
{ {
Quality = this.Quality, Quality = this.Quality,
FrameDelay = this.FrameDelay, FrameDelay = this.FrameDelay,
@ -312,7 +312,7 @@ namespace ImageSharp
Parallel.For( Parallel.For(
0, 0,
target.Height, target.Height,
this.Bootstrapper.ParallelOptions, this.Configuration.ParallelOptions,
y => y =>
{ {
for (int x = 0; x < target.Width; x++) for (int x = 0; x < target.Width; x++)
@ -376,7 +376,7 @@ namespace ImageSharp
/// </exception> /// </exception>
private void Load(Stream stream) private void Load(Stream stream)
{ {
if (!this.Bootstrapper.ImageFormats.Any()) if (!this.Configuration.ImageFormats.Any())
{ {
throw new NotSupportedException("No image formats have been configured."); throw new NotSupportedException("No image formats have been configured.");
} }
@ -411,7 +411,7 @@ namespace ImageSharp
StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder = new StringBuilder();
stringBuilder.AppendLine("Image cannot be loaded. Available formats:"); stringBuilder.AppendLine("Image cannot be loaded. Available formats:");
foreach (IImageFormat format in this.Bootstrapper.ImageFormats) foreach (IImageFormat format in this.Configuration.ImageFormats)
{ {
stringBuilder.AppendLine("-" + format); stringBuilder.AppendLine("-" + format);
} }
@ -428,7 +428,7 @@ namespace ImageSharp
/// </returns> /// </returns>
private bool Decode(Stream stream) private bool Decode(Stream stream)
{ {
int maxHeaderSize = this.Bootstrapper.MaxHeaderSize; int maxHeaderSize = this.Configuration.MaxHeaderSize;
if (maxHeaderSize <= 0) if (maxHeaderSize <= 0)
{ {
return false; return false;
@ -441,7 +441,7 @@ namespace ImageSharp
long startPosition = stream.Position; long startPosition = stream.Position;
stream.Read(header, 0, maxHeaderSize); stream.Read(header, 0, maxHeaderSize);
stream.Position = startPosition; stream.Position = startPosition;
format = this.Bootstrapper.ImageFormats.FirstOrDefault(x => x.IsSupportedFileFormat(header)); format = this.Configuration.ImageFormats.FirstOrDefault(x => x.IsSupportedFileFormat(header));
} }
finally finally
{ {

4
src/ImageSharp/Image/PixelAccessor{TColor}.cs

@ -61,7 +61,7 @@ namespace ImageSharp
this.pixelsBase = (byte*)this.dataPointer.ToPointer(); this.pixelsBase = (byte*)this.dataPointer.ToPointer();
this.PixelSize = Unsafe.SizeOf<TColor>(); this.PixelSize = Unsafe.SizeOf<TColor>();
this.RowStride = this.Width * this.PixelSize; this.RowStride = this.Width * this.PixelSize;
this.ParallelOptions = image.Bootstrapper.ParallelOptions; this.ParallelOptions = image.Configuration.ParallelOptions;
} }
/// <summary> /// <summary>
@ -88,7 +88,7 @@ namespace ImageSharp
this.pixelsBase = (byte*)this.dataPointer.ToPointer(); this.pixelsBase = (byte*)this.dataPointer.ToPointer();
this.PixelSize = Unsafe.SizeOf<TColor>(); this.PixelSize = Unsafe.SizeOf<TColor>();
this.RowStride = this.Width * this.PixelSize; this.RowStride = this.Width * this.PixelSize;
this.ParallelOptions = Bootstrapper.Default.ParallelOptions; this.ParallelOptions = Configuration.Default.ParallelOptions;
} }
/// <summary> /// <summary>

8
src/ImageSharp/ImageFrame.cs

@ -18,11 +18,11 @@ namespace ImageSharp
/// </summary> /// </summary>
/// <param name="width">The width of the image in pixels.</param> /// <param name="width">The width of the image in pixels.</param>
/// <param name="height">The height of the image in pixels.</param> /// <param name="height">The height of the image in pixels.</param>
/// <param name="bootstrapper"> /// <param name="configuration">
/// The bootstrapper providing initialization code which allows extending the library. /// The configuration providing initialization code which allows extending the library.
/// </param> /// </param>
public ImageFrame(int width, int height, Bootstrapper bootstrapper = null) public ImageFrame(int width, int height, Configuration configuration = null)
: base(width, height, bootstrapper) : base(width, height, configuration)
{ {
} }

2
src/ImageSharp/ImageProcessor.cs

@ -26,7 +26,7 @@ namespace ImageSharp.Processors
{ {
if (this.ParallelOptions == null) if (this.ParallelOptions == null)
{ {
this.ParallelOptions = source.Bootstrapper.ParallelOptions; this.ParallelOptions = source.Configuration.ParallelOptions;
} }
try try

2
src/ImageSharp/Quantizers/Quantize.cs

@ -65,7 +65,7 @@ namespace ImageSharp
Parallel.For( Parallel.For(
0, 0,
pixelCount, pixelCount,
source.Bootstrapper.ParallelOptions, source.Configuration.ParallelOptions,
i => i =>
{ {
TColor color = quantized.Palette[Math.Min(palleteCount, quantized.Pixels[i])]; TColor color = quantized.Palette[Math.Min(palleteCount, quantized.Pixels[i])];

2
tests/ImageSharp.Benchmarks/Image/CopyPixels.cs

@ -25,7 +25,7 @@ namespace ImageSharp.Benchmarks.Image
Parallel.For( Parallel.For(
0, 0,
source.Height, source.Height,
Bootstrapper.Default.ParallelOptions, Configuration.Default.ParallelOptions,
y => y =>
{ {
for (int x = 0; x < source.Width; x++) for (int x = 0; x < source.Width; x++)

26
tests/ImageSharp.Tests/BootstrapperTests.cs → tests/ImageSharp.Tests/ConfigurationTests.cs

@ -1,4 +1,4 @@
// <copyright file="BootstrapperTests.cs" company="James Jackson-South"> // <copyright file="ConfigurationTests.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors. // Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright> // </copyright>
@ -11,7 +11,7 @@ namespace ImageSharp.Tests
using Xunit; using Xunit;
using System.Linq; using System.Linq;
public class BootstrapperTests public class ConfigurationTests
{ {
private class TestFormat : IImageFormat private class TestFormat : IImageFormat
{ {
@ -52,7 +52,7 @@ namespace ImageSharp.Tests
exception = Assert.Throws<ArgumentNullException>(() => exception = Assert.Throws<ArgumentNullException>(() =>
{ {
Bootstrapper.Default.AddImageFormat(null); Configuration.Default.AddImageFormat(null);
}); });
var format = new TestFormat(); var format = new TestFormat();
@ -60,7 +60,7 @@ namespace ImageSharp.Tests
exception = Assert.Throws<ArgumentNullException>(() => exception = Assert.Throws<ArgumentNullException>(() =>
{ {
Bootstrapper.Default.AddImageFormat(format); Configuration.Default.AddImageFormat(format);
}); });
Assert.Contains("decoder", exception.Message); Assert.Contains("decoder", exception.Message);
@ -69,7 +69,7 @@ namespace ImageSharp.Tests
exception = Assert.Throws<ArgumentNullException>(() => exception = Assert.Throws<ArgumentNullException>(() =>
{ {
Bootstrapper.Default.AddImageFormat(format); Configuration.Default.AddImageFormat(format);
}); });
Assert.Contains("encoder", exception.Message); Assert.Contains("encoder", exception.Message);
@ -78,7 +78,7 @@ namespace ImageSharp.Tests
exception = Assert.Throws<ArgumentNullException>(() => exception = Assert.Throws<ArgumentNullException>(() =>
{ {
Bootstrapper.Default.AddImageFormat(format); Configuration.Default.AddImageFormat(format);
}); });
Assert.Contains("mime type", exception.Message); Assert.Contains("mime type", exception.Message);
@ -87,7 +87,7 @@ namespace ImageSharp.Tests
exception = Assert.Throws<ArgumentException>(() => exception = Assert.Throws<ArgumentException>(() =>
{ {
Bootstrapper.Default.AddImageFormat(format); Configuration.Default.AddImageFormat(format);
}); });
Assert.Contains("mime type", exception.Message); Assert.Contains("mime type", exception.Message);
@ -96,7 +96,7 @@ namespace ImageSharp.Tests
exception = Assert.Throws<ArgumentNullException>(() => exception = Assert.Throws<ArgumentNullException>(() =>
{ {
Bootstrapper.Default.AddImageFormat(format); Configuration.Default.AddImageFormat(format);
}); });
Assert.Contains("extension", exception.Message); Assert.Contains("extension", exception.Message);
@ -105,7 +105,7 @@ namespace ImageSharp.Tests
exception = Assert.Throws<ArgumentException>(() => exception = Assert.Throws<ArgumentException>(() =>
{ {
Bootstrapper.Default.AddImageFormat(format); Configuration.Default.AddImageFormat(format);
}); });
Assert.Contains("extension", exception.Message); Assert.Contains("extension", exception.Message);
@ -114,7 +114,7 @@ namespace ImageSharp.Tests
exception = Assert.Throws<ArgumentNullException>(() => exception = Assert.Throws<ArgumentNullException>(() =>
{ {
Bootstrapper.Default.AddImageFormat(format); Configuration.Default.AddImageFormat(format);
}); });
Assert.Contains("supported extensions", exception.Message); Assert.Contains("supported extensions", exception.Message);
@ -123,7 +123,7 @@ namespace ImageSharp.Tests
exception = Assert.Throws<ArgumentException>(() => exception = Assert.Throws<ArgumentException>(() =>
{ {
Bootstrapper.Default.AddImageFormat(format); Configuration.Default.AddImageFormat(format);
}); });
Assert.Contains("supported extensions", exception.Message); Assert.Contains("supported extensions", exception.Message);
} }
@ -136,14 +136,14 @@ namespace ImageSharp.Tests
format.Extension = "test"; format.Extension = "test";
var exception = Assert.Throws<ArgumentException>(() => var exception = Assert.Throws<ArgumentException>(() =>
{ {
Bootstrapper.Default.AddImageFormat(format); Configuration.Default.AddImageFormat(format);
}); });
Assert.Contains("should contain", exception.Message); Assert.Contains("should contain", exception.Message);
format.SupportedExtensions = new string[] { "test", "" }; format.SupportedExtensions = new string[] { "test", "" };
exception = Assert.Throws<ArgumentException>(() => exception = Assert.Throws<ArgumentException>(() =>
{ {
Bootstrapper.Default.AddImageFormat(format); Configuration.Default.AddImageFormat(format);
}); });
Assert.Contains("empty values", exception.Message); Assert.Contains("empty values", exception.Message);
} }

8
tests/ImageSharp.Tests/TestFile.cs

@ -42,10 +42,10 @@ namespace ImageSharp.Tests
{ {
// Register the individual image formats. // Register the individual image formats.
// TODO: Is this the best place to do this? // TODO: Is this the best place to do this?
Bootstrapper.Default.AddImageFormat(new PngFormat()); Configuration.Default.AddImageFormat(new PngFormat());
Bootstrapper.Default.AddImageFormat(new JpegFormat()); Configuration.Default.AddImageFormat(new JpegFormat());
Bootstrapper.Default.AddImageFormat(new BmpFormat()); Configuration.Default.AddImageFormat(new BmpFormat());
Bootstrapper.Default.AddImageFormat(new GifFormat()); Configuration.Default.AddImageFormat(new GifFormat());
} }
/// <summary> /// <summary>

2
tests/ImageSharp.Tests/TestUtilities/ImagingTestCaseUtility.cs

@ -96,7 +96,7 @@ namespace ImageSharp.Tests
private static IImageFormat GetImageFormatByExtension(string extension) private static IImageFormat GetImageFormatByExtension(string extension)
{ {
extension = extension.ToLower(); extension = extension.ToLower();
return Bootstrapper.Default.ImageFormats.First(f => f.SupportedExtensions.Contains(extension)); return Configuration.Default.ImageFormats.First(f => f.SupportedExtensions.Contains(extension));
} }
private string GetTestOutputDir() private string GetTestOutputDir()

Loading…
Cancel
Save