Browse Source

Fixing references.

Former-commit-id: cd32f8c955b3fd8ca70862231135ee52a4b97e3a
af/merge-core
James South 12 years ago
parent
commit
c53976a85f
  1. 83
      src/ImageProcessor.UnitTests/Extensions/StringExtensionsUnitTests.cs
  2. 5
      src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj
  3. 62
      src/ImageProcessor.Web.UnitTests/Extensions/StringExtensionsUnitTests.cs
  4. 3
      src/ImageProcessor.Web/NET4/ImageProcessor.Web_NET4.csproj
  5. 3
      src/ImageProcessor.Web/NET45/Caching/DiskCache.cs
  6. 1
      src/ImageProcessor.Web/NET45/Helpers/CommonParameterParserUtility.cs
  7. 2
      src/ImageProcessor.Web/NET45/Processors/Crop.cs
  8. 2
      src/ImageProcessor.Web/NET45/Processors/Resize.cs
  9. 2
      src/ImageProcessor.Web/NET45/Processors/Watermark.cs
  10. 80
      src/ImageProcessor/Common/Extensions/StringExtensions.cs
  11. 1
      src/ImageProcessor/ImageProcessor.csproj

83
src/ImageProcessor.UnitTests/Extensions/StringExtensionsUnitTests.cs

@ -1,83 +0,0 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="StringExtensionsUnitTests.cs" company="James South">
// Copyright (c) James South.
// Licensed under the Apache License, Version 2.0.
// </copyright>
// <summary>
// Provides a test harness for the string extensions
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace ImageProcessor.UnitTests.Extensions
{
using System.Collections.Generic;
using ImageProcessor.Common.Extensions;
using NUnit.Framework;
/// <summary>
/// Test harness for the string extensions
/// </summary>
[TestFixture]
public class StringExtensionsUnitTests
{
/// <summary>
/// Tests the passing to an integer array
/// </summary>
[Test]
public void TestToIntegerArray()
{
Dictionary<string, int[]> data = new Dictionary<string, int[]>
{
{
"123-456,78-90",
new[] { 123, 456, 78, 90 }
},
{
"87390174,741897498,74816,748297,57355",
new[]
{
87390174, 741897498, 74816,
748297, 57355
}
},
{ "1-2-3", new[] { 1, 2, 3 } }
};
foreach (KeyValuePair<string, int[]> item in data)
{
int[] result = item.Key.ToPositiveIntegerArray();
Assert.AreEqual(item.Value, result);
}
}
/// <summary>
/// Tests the passing to an float array
/// </summary>
[Test]
public void TestToFloatArray()
{
Dictionary<string, float[]> data = new Dictionary<string, float[]>
{
{
"12.3-4.56,78-9.0",
new[] { 12.3F, 4.56F, 78, 9 }
},
{
"87390.174,7.41897498,748.16,748297,5.7355",
new[]
{
87390.174F, 7.41897498F,
748.16F, 748297, 5.7355F
}
},
{ "1-2-3", new float[] { 1, 2, 3 } }
};
foreach (KeyValuePair<string, float[]> item in data)
{
float[] result = item.Key.ToPositiveFloatArray();
Assert.AreEqual(item.Value, result);
}
}
}
}

5
src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj

@ -48,7 +48,6 @@
</Compile>
<Compile Include="Extensions\DoubleExtensionsUnitTests.cs" />
<Compile Include="Extensions\IntegerExtensionsUnitTests.cs" />
<Compile Include="Extensions\StringExtensionsUnitTests.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
@ -130,7 +129,5 @@
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
</Target>
<ItemGroup />
<ItemGroup>
<Folder Include="Extensions\" />
</ItemGroup>
<ItemGroup />
</Project>

62
src/ImageProcessor.Web.UnitTests/Extensions/StringExtensionsUnitTests.cs

@ -11,6 +11,8 @@
namespace ImageProcessor.Web.UnitTests.Extensions
{
using System;
using System.Collections.Generic;
using ImageProcessor.Web.Extensions;
using NUnit.Framework;
@ -20,6 +22,66 @@ namespace ImageProcessor.Web.UnitTests.Extensions
[TestFixture]
public class StringExtensionsUnitTests
{
/// <summary>
/// Tests the passing to an integer array
/// </summary>
[Test]
public void TestToIntegerArray()
{
Dictionary<string, int[]> data = new Dictionary<string, int[]>
{
{
"123-456,78-90",
new[] { 123, 456, 78, 90 }
},
{
"87390174,741897498,74816,748297,57355",
new[]
{
87390174, 741897498, 74816,
748297, 57355
}
},
{ "1-2-3", new[] { 1, 2, 3 } }
};
foreach (KeyValuePair<string, int[]> item in data)
{
int[] result = item.Key.ToPositiveIntegerArray();
Assert.AreEqual(item.Value, result);
}
}
/// <summary>
/// Tests the passing to an float array
/// </summary>
[Test]
public void TestToFloatArray()
{
Dictionary<string, float[]> data = new Dictionary<string, float[]>
{
{
"12.3-4.56,78-9.0",
new[] { 12.3F, 4.56F, 78, 9 }
},
{
"87390.174,7.41897498,748.16,748297,5.7355",
new[]
{
87390.174F, 7.41897498F,
748.16F, 748297, 5.7355F
}
},
{ "1-2-3", new float[] { 1, 2, 3 } }
};
foreach (KeyValuePair<string, float[]> item in data)
{
float[] result = item.Key.ToPositiveFloatArray();
Assert.AreEqual(item.Value, result);
}
}
/// <summary>
/// Tests the MD5 fingerprint
/// </summary>

3
src/ImageProcessor.Web/NET4/ImageProcessor.Web_NET4.csproj

@ -98,6 +98,9 @@
<Compile Include="..\NET45\Extensions\DirectoryInfoExtensions.cs">
<Link>DirectoryInfoExtensions.cs</Link>
</Compile>
<Compile Include="..\NET45\Extensions\StringExtensions.cs">
<Link>StringExtensions.cs</Link>
</Compile>
<Compile Include="..\NET45\Helpers\CommonParameterParserUtility.cs">
<Link>CommonParameterParserUtility.cs</Link>
</Compile>

3
src/ImageProcessor.Web/NET45/Caching/DiskCache.cs

@ -20,7 +20,6 @@ namespace ImageProcessor.Web.Caching
using System.Web;
using System.Web.Hosting;
using ImageProcessor.Common.Extensions;
using ImageProcessor.Web.Configuration;
using ImageProcessor.Web.Extensions;
using ImageProcessor.Web.Helpers;
@ -245,7 +244,7 @@ namespace ImageProcessor.Web.Caching
fileInfo.Delete();
count -= 1;
}
// ReSharper disable once EmptyGeneralCatchClause
// ReSharper disable once EmptyGeneralCatchClause
catch
{
// Do nothing; skip to the next file.

1
src/ImageProcessor.Web/NET45/Helpers/CommonParameterParserUtility.cs

@ -17,6 +17,7 @@ namespace ImageProcessor.Web.Helpers
using ImageProcessor.Common.Extensions;
using ImageProcessor.Imaging;
using ImageProcessor.Web.Extensions;
/// <summary>
/// Encapsulates methods to correctly parse querystring parameters.

2
src/ImageProcessor.Web/NET45/Processors/Crop.cs

@ -13,9 +13,9 @@ namespace ImageProcessor.Web.Processors
using System.Text;
using System.Text.RegularExpressions;
using ImageProcessor.Common.Extensions;
using ImageProcessor.Imaging;
using ImageProcessor.Processors;
using ImageProcessor.Web.Extensions;
/// <summary>
/// Crops an image to the given directions.

2
src/ImageProcessor.Web/NET45/Processors/Resize.cs

@ -17,9 +17,9 @@ namespace ImageProcessor.Web.Processors
using System.Text;
using System.Text.RegularExpressions;
using ImageProcessor.Common.Extensions;
using ImageProcessor.Imaging;
using ImageProcessor.Processors;
using ImageProcessor.Web.Extensions;
/// <summary>
/// Resizes an image to the given dimensions.

2
src/ImageProcessor.Web/NET45/Processors/Watermark.cs

@ -15,9 +15,9 @@ namespace ImageProcessor.Web.Processors
using System.Linq;
using System.Text.RegularExpressions;
using ImageProcessor.Common.Extensions;
using ImageProcessor.Imaging;
using ImageProcessor.Processors;
using ImageProcessor.Web.Extensions;
using ImageProcessor.Web.Helpers;
/// <summary>

80
src/ImageProcessor/Common/Extensions/StringExtensions.cs

@ -1,80 +0,0 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="StringExtensions.cs" company="James South">
// Copyright (c) James South.
// Licensed under the Apache License, Version 2.0.
// </copyright>
// <summary>
// Encapsulates a series of time saving extension methods to the <see cref="T:System.String" /> class.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace ImageProcessor.Common.Extensions
{
using System;
using System.Globalization;
using System.Text.RegularExpressions;
/// <summary>
/// Encapsulates a series of time saving extension methods to the <see cref="T:System.String"/> class.
/// </summary>
public static class StringExtensions
{
/// <summary>
/// Creates an array of integers scraped from the String.
/// </summary>
/// <param name="expression">The <see cref="T:System.String">String</see> instance that this method extends.</param>
/// <returns>An array of integers scraped from the String.</returns>
public static int[] ToPositiveIntegerArray(this string expression)
{
if (string.IsNullOrWhiteSpace(expression))
{
throw new ArgumentNullException("expression");
}
Regex regex = new Regex(@"[\d+]+(?=[,-])|[\d+]+(?![,-])", RegexOptions.Compiled);
MatchCollection matchCollection = regex.Matches(expression);
// Get the collections.
int count = matchCollection.Count;
int[] matches = new int[count];
// Loop and parse the int values.
for (int i = 0; i < count; i++)
{
matches[i] = int.Parse(matchCollection[i].Value, CultureInfo.InvariantCulture);
}
return matches;
}
/// <summary>
/// Creates an array of floats scraped from the String.
/// </summary>
/// <param name="expression">The <see cref="T:System.String">String</see> instance that this method extends.</param>
/// <returns>An array of floats scraped from the String.</returns>
public static float[] ToPositiveFloatArray(this string expression)
{
if (string.IsNullOrWhiteSpace(expression))
{
throw new ArgumentNullException("expression");
}
Regex regex = new Regex(@"[\d+\.]+(?=[,-])|[\d+\.]+(?![,-])", RegexOptions.Compiled);
MatchCollection matchCollection = regex.Matches(expression);
// Get the collections.
int count = matchCollection.Count;
float[] matches = new float[count];
// Loop and parse the int values.
for (int i = 0; i < count; i++)
{
matches[i] = float.Parse(matchCollection[i].Value, CultureInfo.InvariantCulture);
}
return matches;
}
}
}

1
src/ImageProcessor/ImageProcessor.csproj

@ -66,7 +66,6 @@
<Compile Include="Common\Extensions\DoubleExtensions.cs" />
<Compile Include="Imaging\Formats\GifInfo.cs" />
<Compile Include="Common\Extensions\IntegerExtensions.cs" />
<Compile Include="Common\Extensions\StringExtensions.cs" />
<Compile Include="Common\Exceptions\ImageFormatException.cs" />
<Compile Include="ImageFactory.cs" />
<Compile Include="Imaging\AnchorPosition.cs" />

Loading…
Cancel
Save