Skip to content

Commit 65e95ad

Browse files
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.
1 parent 72eec6e commit 65e95ad

File tree

7 files changed

+20
-37
lines changed

7 files changed

+20
-37
lines changed

src/ImageProcessor.Web/Configuration/ImageProcessingSection.cs

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,11 @@
1111

1212
namespace ImageProcessor.Web.Configuration
1313
{
14-
#region Using
1514
using System.Configuration;
1615
using System.IO;
1716
using System.Linq;
1817
using System.Xml;
1918
using ImageProcessor.Web.Helpers;
20-
#endregion
2119

2220
/// <summary>
2321
/// Represents an image processing section within a configuration file.
@@ -26,7 +24,6 @@ namespace ImageProcessor.Web.Configuration
2624
public sealed class ImageProcessingSection : ConfigurationSection
2725
{
2826
#region Properties
29-
3027
/// <summary>
3128
/// Gets or sets a value indicating whether to preserve exif meta data.
3229
/// </summary>
@@ -66,6 +63,11 @@ public PluginElementCollection Plugins
6663
return this["plugins"] as PluginElementCollection;
6764
}
6865
}
66+
67+
/// <summary>
68+
/// Gets or sets a value indicating whether to auto load plugins.
69+
/// </summary>
70+
public bool AutoLoadPlugins { get; set; }
6971
#endregion
7072

7173
#region Methods
@@ -80,14 +82,15 @@ public static ImageProcessingSection GetConfiguration()
8082

8183
if (imageProcessingSection != null)
8284
{
85+
imageProcessingSection.AutoLoadPlugins = false;
8386
return imageProcessingSection;
8487
}
8588

8689
string section = ResourceHelpers.ResourceAsString("ImageProcessor.Web.Configuration.Resources.processing.config");
8790
XmlReader reader = new XmlTextReader(new StringReader(section));
8891
imageProcessingSection = new ImageProcessingSection();
8992
imageProcessingSection.DeserializeSection(reader);
90-
93+
imageProcessingSection.AutoLoadPlugins = true;
9194
return imageProcessingSection;
9295
}
9396
#endregion
@@ -251,19 +254,6 @@ public SettingElementCollection Settings
251254
/// </summary>
252255
public class PluginElementCollection : ConfigurationElementCollection
253256
{
254-
/// <summary>
255-
/// Gets or sets a value indicating whether to auto load all plugins.
256-
/// <remarks>Defaults to <value>True</value>.</remarks>
257-
/// </summary>
258-
/// <value>If True plugins are auto discovered and loaded from all assemblies otherwise they must be defined in the configuration file</value>
259-
[ConfigurationProperty("autoLoadPlugins", DefaultValue = true, IsRequired = false)]
260-
public bool AutoLoadPlugins
261-
{
262-
get { return (bool)this["autoLoadPlugins"]; }
263-
264-
set { this["autoLoadPlugins"] = value; }
265-
}
266-
267257
/// <summary>
268258
/// Gets the type of the <see cref="T:System.Configuration.ConfigurationElementCollection"/>.
269259
/// </summary>

src/ImageProcessor.Web/Configuration/ImageProcessorConfiguration.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ private void LoadGraphicsProcessors()
188188
{
189189
if (this.GraphicsProcessors == null)
190190
{
191-
if (GetImageProcessingSection().Plugins.AutoLoadPlugins)
191+
if (GetImageProcessingSection().AutoLoadPlugins)
192192
{
193193
Type type = typeof(IWebGraphicsProcessor);
194194
try
@@ -291,7 +291,7 @@ private void LoadImageServices()
291291
{
292292
if (this.ImageServices == null)
293293
{
294-
if (GetImageSecuritySection().ImageServices.AutoLoadServices)
294+
if (GetImageSecuritySection().AutoLoadServices)
295295
{
296296
Type type = typeof(IImageService);
297297
try

src/ImageProcessor.Web/Configuration/ImageSecuritySection.cs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ public ServiceElementCollection ImageServices
3737
return o as ServiceElementCollection;
3838
}
3939
}
40+
41+
/// <summary>
42+
/// Gets or sets a value indicating whether to auto load services.
43+
/// </summary>
44+
public bool AutoLoadServices { get; set; }
4045
#endregion
4146

4247
#region Methods
@@ -50,14 +55,15 @@ public static ImageSecuritySection GetConfiguration()
5055

5156
if (imageSecuritySection != null)
5257
{
58+
imageSecuritySection.AutoLoadServices = false;
5359
return imageSecuritySection;
5460
}
5561

5662
string section = ResourceHelpers.ResourceAsString("ImageProcessor.Web.Configuration.Resources.security.config");
5763
XmlReader reader = new XmlTextReader(new StringReader(section));
5864
imageSecuritySection = new ImageSecuritySection();
5965
imageSecuritySection.DeserializeSection(reader);
60-
66+
imageSecuritySection.AutoLoadServices = true;
6167
return imageSecuritySection;
6268
}
6369
#endregion
@@ -139,19 +145,6 @@ public WhiteListElementCollection WhiteList
139145
/// </summary>
140146
public class ServiceElementCollection : ConfigurationElementCollection
141147
{
142-
/// <summary>
143-
/// Gets or sets a value indicating whether to auto load all plugins.
144-
/// <remarks>Defaults to <value>True</value>.</remarks>
145-
/// </summary>
146-
/// <value>If True plugins are auto discovered and loaded from all assemblies otherwise they must be defined in the configuration file</value>
147-
[ConfigurationProperty("autoLoadServices", DefaultValue = true, IsRequired = false)]
148-
public bool AutoLoadServices
149-
{
150-
get { return (bool)this["autoLoadServices"]; }
151-
152-
set { this["autoLoadServices"] = value; }
153-
}
154-
155148
/// <summary>
156149
/// Gets the type of the <see cref="T:System.Configuration.ConfigurationElementCollection"/>.
157150
/// </summary>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<processing preserveExifMetaData="false">
22
<presets>
33
</presets>
4-
<plugins autoLoadPlugins="true">
4+
<plugins>
55
<plugin name="Alpha" type="ImageProcessor.Web.Processors.Alpha, ImageProcessor.Web"/>
66
<plugin name="AutoRotate" type="ImageProcessor.Web.Processors.AutoRotate, ImageProcessor.Web"/>
77
<plugin name="BackgroundColor" type="ImageProcessor.Web.Processors.BackgroundColor, ImageProcessor.Web"/>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<security>
2-
<services autoLoadServices="true">
2+
<services>
33
<service name="LocalFileImageService" type="ImageProcessor.Web.Services.LocalFileImageService, ImageProcessor.Web"/>
44
<service prefix="remote.axd" name="RemoteImageService" type="ImageProcessor.Web.Services.RemoteImageService, ImageProcessor.Web">
55
<settings>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<processing preserveExifMetaData="false">
22
<presets>
33
</presets>
4-
<plugins autoLoadPlugins="true">
4+
<plugins>
55
<plugin name="Alpha" type="ImageProcessor.Web.Processors.Alpha, ImageProcessor.Web"/>
66
<plugin name="AutoRotate" type="ImageProcessor.Web.Processors.AutoRotate, ImageProcessor.Web"/>
77
<plugin name="BackgroundColor" type="ImageProcessor.Web.Processors.BackgroundColor, ImageProcessor.Web"/>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8" ?>
22
<security>
3-
<services autoLoadServices="true">
3+
<services>
44
<service name="LocalFileImageService" type="ImageProcessor.Web.Services.LocalFileImageService, ImageProcessor.Web"/>
55
<service prefix="remote.axd" name="RemoteImageService" type="ImageProcessor.Web.Services.RemoteImageService, ImageProcessor.Web">
66
<settings>

0 commit comments

Comments
 (0)