Browse Source

Removing autoload check.

The existing logic didn't make sense so it has been changed to only
prevent autoloading the plugins/services if configuration is present.


Former-commit-id: 586f8a17c5179efac2f46e9e84db9576f083432b
Former-commit-id: 02d420ca613582de5e8a091dd88fc85cdd712e6d
pull/17/head
James South 11 years ago
parent
commit
c74bfb317a
  1. 24
      src/ImageProcessor.Web/Configuration/ImageProcessingSection.cs
  2. 4
      src/ImageProcessor.Web/Configuration/ImageProcessorConfiguration.cs
  3. 21
      src/ImageProcessor.Web/Configuration/ImageSecuritySection.cs
  4. 2
      src/ImageProcessor.Web/Configuration/Resources/processing.config
  5. 2
      src/ImageProcessor.Web/Configuration/Resources/security.config
  6. 2
      src/TestWebsites/MVC/config/imageprocessor/processing.config
  7. 2
      src/TestWebsites/MVC/config/imageprocessor/security.config

24
src/ImageProcessor.Web/Configuration/ImageProcessingSection.cs

@ -11,13 +11,11 @@
namespace ImageProcessor.Web.Configuration
{
#region Using
using System.Configuration;
using System.IO;
using System.Linq;
using System.Xml;
using ImageProcessor.Web.Helpers;
#endregion
/// <summary>
/// Represents an image processing section within a configuration file.
@ -26,7 +24,6 @@ namespace ImageProcessor.Web.Configuration
public sealed class ImageProcessingSection : ConfigurationSection
{
#region Properties
/// <summary>
/// Gets or sets a value indicating whether to preserve exif meta data.
/// </summary>
@ -66,6 +63,11 @@ namespace ImageProcessor.Web.Configuration
return this["plugins"] as PluginElementCollection;
}
}
/// <summary>
/// Gets or sets a value indicating whether to auto load plugins.
/// </summary>
public bool AutoLoadPlugins { get; set; }
#endregion
#region Methods
@ -80,6 +82,7 @@ namespace ImageProcessor.Web.Configuration
if (imageProcessingSection != null)
{
imageProcessingSection.AutoLoadPlugins = false;
return imageProcessingSection;
}
@ -87,7 +90,7 @@ namespace ImageProcessor.Web.Configuration
XmlReader reader = new XmlTextReader(new StringReader(section));
imageProcessingSection = new ImageProcessingSection();
imageProcessingSection.DeserializeSection(reader);
imageProcessingSection.AutoLoadPlugins = true;
return imageProcessingSection;
}
#endregion
@ -251,19 +254,6 @@ namespace ImageProcessor.Web.Configuration
/// </summary>
public class PluginElementCollection : ConfigurationElementCollection
{
/// <summary>
/// Gets or sets a value indicating whether to auto load all plugins.
/// <remarks>Defaults to <value>True</value>.</remarks>
/// </summary>
/// <value>If True plugins are auto discovered and loaded from all assemblies otherwise they must be defined in the configuration file</value>
[ConfigurationProperty("autoLoadPlugins", DefaultValue = true, IsRequired = false)]
public bool AutoLoadPlugins
{
get { return (bool)this["autoLoadPlugins"]; }
set { this["autoLoadPlugins"] = value; }
}
/// <summary>
/// Gets the type of the <see cref="T:System.Configuration.ConfigurationElementCollection"/>.
/// </summary>

4
src/ImageProcessor.Web/Configuration/ImageProcessorConfiguration.cs

@ -188,7 +188,7 @@ namespace ImageProcessor.Web.Configuration
{
if (this.GraphicsProcessors == null)
{
if (GetImageProcessingSection().Plugins.AutoLoadPlugins)
if (GetImageProcessingSection().AutoLoadPlugins)
{
Type type = typeof(IWebGraphicsProcessor);
try
@ -291,7 +291,7 @@ namespace ImageProcessor.Web.Configuration
{
if (this.ImageServices == null)
{
if (GetImageSecuritySection().ImageServices.AutoLoadServices)
if (GetImageSecuritySection().AutoLoadServices)
{
Type type = typeof(IImageService);
try

21
src/ImageProcessor.Web/Configuration/ImageSecuritySection.cs

@ -37,6 +37,11 @@ namespace ImageProcessor.Web.Configuration
return o as ServiceElementCollection;
}
}
/// <summary>
/// Gets or sets a value indicating whether to auto load services.
/// </summary>
public bool AutoLoadServices { get; set; }
#endregion
#region Methods
@ -50,6 +55,7 @@ namespace ImageProcessor.Web.Configuration
if (imageSecuritySection != null)
{
imageSecuritySection.AutoLoadServices = false;
return imageSecuritySection;
}
@ -57,7 +63,7 @@ namespace ImageProcessor.Web.Configuration
XmlReader reader = new XmlTextReader(new StringReader(section));
imageSecuritySection = new ImageSecuritySection();
imageSecuritySection.DeserializeSection(reader);
imageSecuritySection.AutoLoadServices = true;
return imageSecuritySection;
}
#endregion
@ -139,19 +145,6 @@ namespace ImageProcessor.Web.Configuration
/// </summary>
public class ServiceElementCollection : ConfigurationElementCollection
{
/// <summary>
/// Gets or sets a value indicating whether to auto load all plugins.
/// <remarks>Defaults to <value>True</value>.</remarks>
/// </summary>
/// <value>If True plugins are auto discovered and loaded from all assemblies otherwise they must be defined in the configuration file</value>
[ConfigurationProperty("autoLoadServices", DefaultValue = true, IsRequired = false)]
public bool AutoLoadServices
{
get { return (bool)this["autoLoadServices"]; }
set { this["autoLoadServices"] = value; }
}
/// <summary>
/// Gets the type of the <see cref="T:System.Configuration.ConfigurationElementCollection"/>.
/// </summary>

2
src/ImageProcessor.Web/Configuration/Resources/processing.config

@ -1,7 +1,7 @@
<processing preserveExifMetaData="false">
<presets>
</presets>
<plugins autoLoadPlugins="true">
<plugins>
<plugin name="Alpha" type="ImageProcessor.Web.Processors.Alpha, ImageProcessor.Web"/>
<plugin name="AutoRotate" type="ImageProcessor.Web.Processors.AutoRotate, ImageProcessor.Web"/>
<plugin name="BackgroundColor" type="ImageProcessor.Web.Processors.BackgroundColor, ImageProcessor.Web"/>

2
src/ImageProcessor.Web/Configuration/Resources/security.config

@ -1,5 +1,5 @@
<security>
<services autoLoadServices="true">
<services>
<service name="LocalFileImageService" type="ImageProcessor.Web.Services.LocalFileImageService, ImageProcessor.Web"/>
<service prefix="remote.axd" name="RemoteImageService" type="ImageProcessor.Web.Services.RemoteImageService, ImageProcessor.Web">
<settings>

2
src/TestWebsites/MVC/config/imageprocessor/processing.config

@ -1,7 +1,7 @@
<processing preserveExifMetaData="false">
<presets>
</presets>
<plugins autoLoadPlugins="true">
<plugins>
<plugin name="Alpha" type="ImageProcessor.Web.Processors.Alpha, ImageProcessor.Web"/>
<plugin name="AutoRotate" type="ImageProcessor.Web.Processors.AutoRotate, ImageProcessor.Web"/>
<plugin name="BackgroundColor" type="ImageProcessor.Web.Processors.BackgroundColor, ImageProcessor.Web"/>

2
src/TestWebsites/MVC/config/imageprocessor/security.config

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<security>
<services autoLoadServices="true">
<services>
<service name="LocalFileImageService" type="ImageProcessor.Web.Services.LocalFileImageService, ImageProcessor.Web"/>
<service prefix="remote.axd" name="RemoteImageService" type="ImageProcessor.Web.Services.RemoteImageService, ImageProcessor.Web">
<settings>

Loading…
Cancel
Save