Browse Source

Merge remote-tracking branch 'origin/dev' into V2

Former-commit-id: 2c43388625a486f4eda3ef296ab69d17ce51d650
af/merge-core
James South 12 years ago
parent
commit
844fbe5e15
  1. 2
      build/Build.bat
  2. 9
      src/ImageProcessor.Web/NET45/Configuration/ImageProcessorConfiguration.cs
  3. 41
      src/ImageProcessor/Common/Extensions/AssemblyExtensions.cs
  4. 6
      src/ImageProcessor/Configuration/ImageProcessorBootstrapper.cs
  5. 1
      src/ImageProcessor/ImageProcessor.csproj

2
build/Build.bat

@ -8,7 +8,7 @@ ECHO Building ImageProcessor %version%, ImageProcess.Web %webversion% and ImageP
ECHO Installing the Microsoft.Bcl.Build package before anything else, otherwise you'd have to run build.cmd twice ECHO Installing the Microsoft.Bcl.Build package before anything else, otherwise you'd have to run build.cmd twice
SET nuGetFolder=%CD%\..\src\packages\ SET nuGetFolder=%CD%\..\src\packages\
..\src\.nuget\NuGet.exe install ..\src\ImageProcessor.Web\NET45\packages.config -OutputDirectory %nuGetFolder% ..\src\.nuget\NuGet.exe install ..\src\ImageProcessor.Web\NET4\packages.config -OutputDirectory %nuGetFolder%
ECHO Removing _BuildOutput directory so everything is nice and clean ECHO Removing _BuildOutput directory so everything is nice and clean
RD _BuildOutput /q /s RD _BuildOutput /q /s

9
src/ImageProcessor.Web/NET45/Configuration/ImageProcessorConfiguration.cs

@ -10,18 +10,17 @@
// -------------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------------
namespace ImageProcessor.Web.Configuration namespace ImageProcessor.Web.Configuration
{ {
#region Using
using System; using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.Web.Compilation; using System.Web.Compilation;
using ImageProcessor.Common.Extensions;
using ImageProcessor.Processors; using ImageProcessor.Processors;
using ImageProcessor.Web.Processors; using ImageProcessor.Web.Processors;
#endregion
/// <summary> /// <summary>
/// Encapsulates methods to allow the retrieval of ImageProcessor settings. /// Encapsulates methods to allow the retrieval of ImageProcessor settings.
/// <see href="http://csharpindepth.com/Articles/General/Singleton.aspx"/> /// <see href="http://csharpindepth.com/Articles/General/Singleton.aspx"/>
@ -301,8 +300,8 @@ namespace ImageProcessor.Web.Configuration
// Build a list of native IGraphicsProcessor instances. // Build a list of native IGraphicsProcessor instances.
List<Type> availableTypes = BuildManager.GetReferencedAssemblies() List<Type> availableTypes = BuildManager.GetReferencedAssemblies()
.Cast<Assembly>() .Cast<Assembly>()
.SelectMany(s => s.GetTypes()) .SelectMany(s => s.GetLoadableTypes())
.Where(t => t != null && type.IsAssignableFrom(t) && t.IsClass && !t.IsAbstract) .Where(t => type.IsAssignableFrom(t) && t.IsClass && !t.IsAbstract)
.ToList(); .ToList();
// Create them and add. // Create them and add.

41
src/ImageProcessor/Common/Extensions/AssemblyExtensions.cs

@ -0,0 +1,41 @@

namespace ImageProcessor.Common.Extensions
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
/// <summary>
/// Encapsulates a series of time saving extension methods to the <see cref="T:System.Reflection.Assembly"/> class.
/// </summary>
public static class AssemblyExtensions
{
/// <summary>
/// Gets a collection of loadable types from the given assembly.
/// Adapted from <see href="http://stackoverflow.com/questions/7889228/how-to-prevent-reflectiontypeloadexception-when-calling-assembly-gettypes"/>
/// </summary>
/// <param name="assembly">
/// The <see cref="System.Reflection.Assembly"/> to load the types from.
/// </param>
/// <returns>
/// The loadable <see cref="System.Collections.Generic.IEnumerable{Type}"/>.
/// </returns>
public static IEnumerable<Type> GetLoadableTypes(this Assembly assembly)
{
if (assembly == null)
{
throw new ArgumentNullException("assembly");
}
try
{
return assembly.GetTypes();
}
catch (ReflectionTypeLoadException ex)
{
return ex.Types.Where(t => t != null);
}
}
}
}

6
src/ImageProcessor/Configuration/ImageProcessorBootstrapper.cs

@ -13,8 +13,8 @@ namespace ImageProcessor.Configuration
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using ImageProcessor.Common.Exceptions; using ImageProcessor.Common.Exceptions;
using ImageProcessor.Common.Extensions;
using ImageProcessor.Imaging.Formats; using ImageProcessor.Imaging.Formats;
/// <summary> /// <summary>
@ -65,8 +65,8 @@ namespace ImageProcessor.Configuration
Type type = typeof(ISupportedImageFormat); Type type = typeof(ISupportedImageFormat);
List<Type> availableTypes = AppDomain.CurrentDomain List<Type> availableTypes = AppDomain.CurrentDomain
.GetAssemblies() .GetAssemblies()
.SelectMany(s => s.GetTypes()) .SelectMany(s => s.GetLoadableTypes())
.Where(t => t != null && type.IsAssignableFrom(t) && t.IsClass && !t.IsAbstract) .Where(t => type.IsAssignableFrom(t) && t.IsClass && !t.IsAbstract)
.ToList(); .ToList();
this.SupportedImageFormats = availableTypes this.SupportedImageFormats = availableTypes

1
src/ImageProcessor/ImageProcessor.csproj

@ -59,6 +59,7 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Common\Extensions\AssemblyExtensions.cs" />
<Compile Include="Configuration\ImageProcessorBootstrapper.cs" /> <Compile Include="Configuration\ImageProcessorBootstrapper.cs" />
<Compile Include="Common\Exceptions\ImageProcessingException.cs" /> <Compile Include="Common\Exceptions\ImageProcessingException.cs" />
<Compile Include="Common\Extensions\DoubleExtensions.cs" /> <Compile Include="Common\Extensions\DoubleExtensions.cs" />

Loading…
Cancel
Save