Browse Source

Fixed var warnings.

af/merge-core
Dirk Lemstra 9 years ago
parent
commit
b33d633df4
  1. 10
      src/ImageSharp/MetaData/Profiles/Exif/ExifProfile.cs
  2. 6
      src/ImageSharp/MetaData/Profiles/Exif/ExifReader.cs
  3. 4
      src/ImageSharp/MetaData/Profiles/Exif/ExifValue.cs
  4. 25
      tests/ImageSharp.Tests/ConfigurationTests.cs

10
src/ImageSharp/MetaData/Profiles/Exif/ExifProfile.cs

@ -136,7 +136,7 @@ namespace ImageSharp
return null;
}
using (MemoryStream memStream = new MemoryStream(this.data, this.thumbnailOffset, this.thumbnailLength))
using (var memStream = new MemoryStream(this.data, this.thumbnailOffset, this.thumbnailLength))
{
return Image.Load<TPixel>(memStream);
}
@ -201,7 +201,7 @@ namespace ImageSharp
}
}
ExifValue newExifValue = ExifValue.Create(tag, value);
var newExifValue = ExifValue.Create(tag, value);
this.values.Add(newExifValue);
}
@ -221,7 +221,7 @@ namespace ImageSharp
return null;
}
ExifWriter writer = new ExifWriter(this.values, this.Parts);
var writer = new ExifWriter(this.values, this.Parts);
return writer.GetData();
}
@ -248,7 +248,7 @@ namespace ImageSharp
this.RemoveValue(value.Tag);
}
Rational newResolution = new Rational(resolution, false);
var newResolution = new Rational(resolution, false);
this.SetValue(tag, newResolution);
}
@ -265,7 +265,7 @@ namespace ImageSharp
return;
}
ExifReader reader = new ExifReader();
var reader = new ExifReader();
this.values = reader.Read(this.data);
this.invalidTags = new List<ExifTag>(reader.InvalidTags);
this.thumbnailOffset = (int)reader.ThumbnailOffset;

6
src/ImageSharp/MetaData/Profiles/Exif/ExifReader.cs

@ -75,7 +75,7 @@ namespace ImageSharp
{
DebugGuard.NotNull(data, nameof(data));
Collection<ExifValue> result = new Collection<ExifValue>();
var result = new Collection<ExifValue>();
this.exifData = data;
@ -357,7 +357,7 @@ namespace ImageSharp
private TEnum ToEnum<TEnum>(int value, TEnum defaultValue)
where TEnum : struct
{
TEnum enumValue = (TEnum)(object)value;
var enumValue = (TEnum)(object)value;
if (Enum.GetValues(typeof(TEnum)).Cast<TEnum>().Any(v => v.Equals(enumValue)))
{
return enumValue;
@ -403,7 +403,7 @@ namespace ImageSharp
private void GetThumbnail(uint offset)
{
Collection<ExifValue> values = new Collection<ExifValue>();
var values = new Collection<ExifValue>();
this.AddValues(values, offset);
foreach (ExifValue value in values)

4
src/ImageSharp/MetaData/Profiles/Exif/ExifValue.cs

@ -39,7 +39,7 @@ namespace ImageSharp
}
else
{
Array array = (Array)other.exifValue;
var array = (Array)other.exifValue;
this.exifValue = array.Clone();
}
}
@ -264,7 +264,7 @@ namespace ImageSharp
return this.ToString(this.exifValue);
}
StringBuilder sb = new StringBuilder();
var sb = new StringBuilder();
foreach (object value in (Array)this.exifValue)
{
sb.Append(this.ToString(value));

25
tests/ImageSharp.Tests/ConfigurationTests.cs

@ -7,6 +7,7 @@ namespace ImageSharp.Tests
{
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using ImageSharp.Formats;
@ -23,7 +24,7 @@ namespace ImageSharp.Tests
[Fact]
public void DefaultsToLocalFileSystem()
{
Configuration configuration = Configuration.CreateDefaultInstance();
var configuration = Configuration.CreateDefaultInstance();
ImageSharp.IO.IFileSystem fs = configuration.FileSystem;
@ -33,7 +34,7 @@ namespace ImageSharp.Tests
[Fact]
public void IfAutoloadWellknwonFormatesIsTrueAllFormateAreLoaded()
{
Configuration configuration = Configuration.CreateDefaultInstance();
var configuration = Configuration.CreateDefaultInstance();
Assert.Equal(4, configuration.ImageFormats.Count);
}
@ -95,7 +96,7 @@ namespace ImageSharp.Tests
[Fact]
public void TestAddImageFormatThrowsWithNullEncoder()
{
TestFormat format = new TestFormat { Encoder = null };
var format = new TestFormat { Encoder = null };
Assert.Throws<ArgumentNullException>(() =>
{
@ -110,7 +111,7 @@ namespace ImageSharp.Tests
[Fact]
public void TestAddImageFormatThrowsWithNullDecoder()
{
TestFormat format = new TestFormat { Decoder = null };
var format = new TestFormat { Decoder = null };
Assert.Throws<ArgumentNullException>(() =>
{
@ -125,7 +126,7 @@ namespace ImageSharp.Tests
[Fact]
public void TestAddImageFormatThrowsWithNullOrEmptyMimeType()
{
TestFormat format = new TestFormat { MimeType = null };
var format = new TestFormat { MimeType = null };
Assert.Throws<ArgumentNullException>(() =>
{
@ -147,7 +148,7 @@ namespace ImageSharp.Tests
[Fact]
public void TestAddImageFormatThrowsWithNullOrEmptyExtension()
{
TestFormat format = new TestFormat { Extension = null };
var format = new TestFormat { Extension = null };
Assert.Throws<ArgumentNullException>(() =>
{
@ -169,7 +170,7 @@ namespace ImageSharp.Tests
[Fact]
public void TestAddImageFormatThrowsWenSupportedExtensionsIsNullOrEmpty()
{
TestFormat format = new TestFormat { SupportedExtensions = null };
var format = new TestFormat { SupportedExtensions = null };
Assert.Throws<ArgumentNullException>(() =>
{
@ -191,7 +192,7 @@ namespace ImageSharp.Tests
[Fact]
public void TestAddImageFormatThrowsWithoutDefaultExtension()
{
TestFormat format = new TestFormat { Extension = "test" };
var format = new TestFormat { Extension = "test" };
Assert.Throws<ArgumentException>(() =>
{
@ -206,7 +207,7 @@ namespace ImageSharp.Tests
[Fact]
public void TestAddImageFormatThrowsWithEmptySupportedExtension()
{
TestFormat format = new TestFormat
var format = new TestFormat
{
Extension = "test",
SupportedExtensions = new[] { "test", string.Empty }
@ -238,7 +239,7 @@ namespace ImageSharp.Tests
{
Configuration.Default.AddImageFormat(new PngFormat());
Image<Rgba32> image = new Image<Rgba32>(1, 1);
var image = new Image<Rgba32>(1, 1);
Assert.Equal(image.Configuration.ParallelOptions, Configuration.Default.ParallelOptions);
Assert.Equal(image.Configuration.ImageFormats, Configuration.Default.ImageFormats);
}
@ -251,8 +252,8 @@ namespace ImageSharp.Tests
{
Configuration.Default.AddImageFormat(new PngFormat());
Image<Rgba32> image = new Image<Rgba32>(1, 1);
Image<Rgba32> image2 = new Image<Rgba32>(image);
var image = new Image<Rgba32>(1, 1);
var image2 = new Image<Rgba32>(image);
Assert.Equal(image2.Configuration.ParallelOptions, image.Configuration.ParallelOptions);
Assert.True(image2.Configuration.ImageFormats.SequenceEqual(image.Configuration.ImageFormats));
}

Loading…
Cancel
Save