|
|
@ -12,6 +12,7 @@ namespace ImageProcessor.Web.Config |
|
|
{ |
|
|
{ |
|
|
#region Using
|
|
|
#region Using
|
|
|
using System; |
|
|
using System; |
|
|
|
|
|
using System.Collections.Concurrent; |
|
|
using System.Collections.Generic; |
|
|
using System.Collections.Generic; |
|
|
using System.Linq; |
|
|
using System.Linq; |
|
|
using System.Reflection; |
|
|
using System.Reflection; |
|
|
@ -37,14 +38,14 @@ namespace ImageProcessor.Web.Config |
|
|
/// A collection of the <see cref="T:ImageProcessor.Web.Config.ImageProcessingSection.SettingElementCollection"/> elements
|
|
|
/// A collection of the <see cref="T:ImageProcessor.Web.Config.ImageProcessingSection.SettingElementCollection"/> elements
|
|
|
/// for available plugins.
|
|
|
/// for available plugins.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
private static readonly Dictionary<string, Dictionary<string, string>> PluginSettings = |
|
|
private static readonly ConcurrentDictionary<string, Dictionary<string, string>> PluginSettings = |
|
|
new Dictionary<string, Dictionary<string, string>>(); |
|
|
new ConcurrentDictionary<string, Dictionary<string, string>>(); |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// A collection of the processing presets defined in the configuration.
|
|
|
/// A collection of the processing presets defined in the configuration.
|
|
|
/// for available plugins.
|
|
|
/// for available plugins.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
private static readonly Dictionary<string, string> PresetSettings = new Dictionary<string, string>(); |
|
|
private static readonly ConcurrentDictionary<string, string> PresetSettings = new ConcurrentDictionary<string, string>(); |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// The processing configuration section from the current application configuration.
|
|
|
/// The processing configuration section from the current application configuration.
|
|
|
@ -185,33 +186,26 @@ namespace ImageProcessor.Web.Config |
|
|
|
|
|
|
|
|
#region Methods
|
|
|
#region Methods
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Returns the collection of the processing presets defined in the configuration.
|
|
|
/// Returns the processing instructions matching the preset defined in the configuration.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
/// <param name="name">
|
|
|
/// <param name="name">
|
|
|
/// The name of the plugin to get the settings for.
|
|
|
/// The name of the plugin to get the settings for.
|
|
|
/// </param>
|
|
|
/// </param>
|
|
|
/// <returns>
|
|
|
/// <returns>
|
|
|
/// The <see cref="T:Systems.Collections.Generic.Dictionary{string, string}"/> containing the processing presets defined in the configuration.
|
|
|
/// The <see cref="T:Systems.String"/> the processing instructions.
|
|
|
/// </returns>
|
|
|
/// </returns>
|
|
|
public string GetPresetSettings(string name) |
|
|
public string GetPresetSettings(string name) |
|
|
{ |
|
|
{ |
|
|
if (!PresetSettings.ContainsKey(name)) |
|
|
return PresetSettings.GetOrAdd( |
|
|
{ |
|
|
name, |
|
|
var presetElement = |
|
|
n => |
|
|
GetImageProcessingSection().Presets |
|
|
{ |
|
|
.Cast<ImageProcessingSection.PresetElement>() |
|
|
ImageProcessingSection.PresetElement presetElement = GetImageProcessingSection() |
|
|
.FirstOrDefault(x => x.Name == name); |
|
|
.Presets |
|
|
|
|
|
.Cast<ImageProcessingSection.PresetElement>() |
|
|
if (presetElement != null) |
|
|
.FirstOrDefault(x => x.Name == n); |
|
|
{ |
|
|
return presetElement != null ? presetElement.Value : null; |
|
|
PresetSettings[presetElement.Name] = presetElement.Value; |
|
|
}); |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
string preset; |
|
|
|
|
|
PresetSettings.TryGetValue(name, out preset); |
|
|
|
|
|
|
|
|
|
|
|
return preset; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
@ -225,31 +219,30 @@ namespace ImageProcessor.Web.Config |
|
|
/// </returns>
|
|
|
/// </returns>
|
|
|
public Dictionary<string, string> GetPluginSettings(string name) |
|
|
public Dictionary<string, string> GetPluginSettings(string name) |
|
|
{ |
|
|
{ |
|
|
if (!PluginSettings.ContainsKey(name)) |
|
|
return PluginSettings.GetOrAdd( |
|
|
{ |
|
|
name, |
|
|
var pluginElement = |
|
|
n => |
|
|
GetImageProcessingSection().Plugins |
|
|
|
|
|
.Cast<ImageProcessingSection.PluginElement>() |
|
|
|
|
|
.FirstOrDefault(x => x.Name == name); |
|
|
|
|
|
|
|
|
|
|
|
Dictionary<string, string> settings; |
|
|
|
|
|
|
|
|
|
|
|
if (pluginElement != null) |
|
|
|
|
|
{ |
|
|
{ |
|
|
settings = pluginElement.Settings |
|
|
ImageProcessingSection.PluginElement pluginElement = GetImageProcessingSection() |
|
|
.Cast<ImageProcessingSection.SettingElement>() |
|
|
.Plugins |
|
|
.ToDictionary(setting => setting.Key, setting => setting.Value); |
|
|
.Cast<ImageProcessingSection.PluginElement>() |
|
|
} |
|
|
.FirstOrDefault(x => x.Name == n); |
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
settings = new Dictionary<string, string>(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
PluginSettings.Add(name, settings); |
|
|
Dictionary<string, string> settings; |
|
|
return settings; |
|
|
|
|
|
} |
|
|
if (pluginElement != null) |
|
|
|
|
|
{ |
|
|
|
|
|
settings = pluginElement.Settings |
|
|
|
|
|
.Cast<ImageProcessingSection.SettingElement>() |
|
|
|
|
|
.ToDictionary(setting => setting.Key, setting => setting.Value); |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
settings = new Dictionary<string, string>(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return PluginSettings[name]; |
|
|
return settings; |
|
|
|
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
|