Browse Source

Merge remote-tracking branch 'origin/dev'

Conflicts:
	src/ImageProcessor.Web/NET45/Config/ImageProcessorConfig.cs
	src/ImageProcessor.Web/NET45/Properties/AssemblyInfo.cs

Former-commit-id: 7e9cd96b2b2a45695f003f08bda3275a00901d63
pull/17/head
James South 12 years ago
parent
commit
a4f49d6c72
  1. 95
      src/ImageProcessor.Web/NET45/Config/ImageProcessorConfig.cs
  2. 5
      src/ImageProcessor.Web/NET45/Properties/AssemblyInfo.cs
  3. BIN
      src/Nuget/ImageProcessor.Web.3.1.1.0.nupkg

95
src/ImageProcessor.Web/NET45/Config/ImageProcessorConfig.cs

@ -17,6 +17,7 @@ namespace ImageProcessor.Web.Config
using System.Linq;
using System.Reflection;
using System.Text;
using System.Web.Compilation;
using ImageProcessor.Processors;
#endregion
@ -288,21 +289,20 @@ namespace ImageProcessor.Web.Config
{
if (this.GraphicsProcessors == null)
{
try
if (GetImageProcessingSection().Plugins.AutoLoadPlugins)
{
if (GetImageProcessingSection().Plugins.AutoLoadPlugins)
Type type = typeof(IGraphicsProcessor);
try
{
// Build a list of native IGraphicsProcessor instances.
Type type = typeof(IGraphicsProcessor);
IEnumerable<Type> types =
AppDomain.CurrentDomain.GetAssemblies()
.SelectMany(s => s.GetTypes())
.Where(p => type.IsAssignableFrom(p) && p.IsClass && !p.IsAbstract)
.ToList();
List<Type> availableTypes = BuildManager.GetReferencedAssemblies()
.Cast<Assembly>()
.SelectMany(s => s.GetTypes())
.Where(t => t != null && type.IsAssignableFrom(t) && t.IsClass && !t.IsAbstract)
.ToList();
// Create them and add.
this.GraphicsProcessors =
types.Select(x => (Activator.CreateInstance(x) as IGraphicsProcessor)).ToList();
this.GraphicsProcessors = availableTypes.Select(x => (Activator.CreateInstance(x) as IGraphicsProcessor)).ToList();
// Add the available settings.
foreach (IGraphicsProcessor processor in this.GraphicsProcessors)
@ -310,55 +310,46 @@ namespace ImageProcessor.Web.Config
processor.Settings = this.GetPluginSettings(processor.GetType().Name);
}
}
else
catch (ReflectionTypeLoadException ex)
{
ImageProcessingSection.PluginElementCollection pluginConfigs = imageProcessingSection.Plugins;
this.GraphicsProcessors = new List<IGraphicsProcessor>();
foreach (ImageProcessingSection.PluginElement pluginConfig in pluginConfigs)
{
Type type = Type.GetType(pluginConfig.Type);
if (type == null)
{
throw new ArgumentException("Couldn't load IGraphicsProcessor: " + pluginConfig.Type);
}
this.GraphicsProcessors.Add(Activator.CreateInstance(type) as IGraphicsProcessor);
}
// Add the available settings.
foreach (IGraphicsProcessor processor in this.GraphicsProcessors)
{
processor.Settings = this.GetPluginSettings(processor.GetType().Name);
}
this.LoadGraphicsProcessorsFromConfiguration();
}
}
catch (ReflectionTypeLoadException ex)
else
{
StringBuilder stringBuilder = new StringBuilder();
foreach (Exception exception in ex.LoaderExceptions)
{
stringBuilder.AppendLine(exception.Message);
if (exception is FileNotFoundException)
{
FileNotFoundException fileNotFoundException = exception as FileNotFoundException;
if (!string.IsNullOrEmpty(fileNotFoundException.FusionLog))
{
stringBuilder.AppendLine("Fusion Log:");
stringBuilder.AppendLine(fileNotFoundException.FusionLog);
}
}
stringBuilder.AppendLine();
}
this.LoadGraphicsProcessorsFromConfiguration();
}
}
}
string errorMessage = stringBuilder.ToString();
/// <summary>
/// Loads graphics processors from configuration.
/// </summary>
/// <exception cref="TypeLoadException">
/// Thrown when an <see cref="IGraphicsProcessor"/> cannot be loaded.
/// </exception>
private void LoadGraphicsProcessorsFromConfiguration()
{
ImageProcessingSection.PluginElementCollection pluginConfigs = imageProcessingSection.Plugins;
this.GraphicsProcessors = new List<IGraphicsProcessor>();
foreach (ImageProcessingSection.PluginElement pluginConfig in pluginConfigs)
{
Type type = Type.GetType(pluginConfig.Type);
// Display or log the error based on your application.
throw new Exception(errorMessage);
if (type == null)
{
throw new TypeLoadException("Couldn't load IGraphicsProcessor: " + pluginConfig.Type);
}
this.GraphicsProcessors.Add(Activator.CreateInstance(type) as IGraphicsProcessor);
}
// Add the available settings.
foreach (IGraphicsProcessor processor in this.GraphicsProcessors)
{
processor.Settings = this.GetPluginSettings(processor.GetType().Name);
}
}
#endregion
}
}
}

5
src/ImageProcessor.Web/NET45/Properties/AssemblyInfo.cs

@ -31,6 +31,5 @@ using System.Runtime.InteropServices;
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("3.1.0.0")]
[assembly: AssemblyFileVersion("3.1.0.0")]
[assembly: AssemblyVersion("3.1.1.0")]
[assembly: AssemblyFileVersion("3.1.1.0")]

BIN
src/Nuget/ImageProcessor.Web.3.1.1.0.nupkg

Binary file not shown.
Loading…
Cancel
Save