diff --git a/src/ImageProcessor.Web/Helpers/CommonParameterParserUtility.cs b/src/ImageProcessor.Web/Helpers/CommonParameterParserUtility.cs
index a42ed735c..c47fc1611 100644
--- a/src/ImageProcessor.Web/Helpers/CommonParameterParserUtility.cs
+++ b/src/ImageProcessor.Web/Helpers/CommonParameterParserUtility.cs
@@ -1,13 +1,9 @@
// --------------------------------------------------------------------------------------------------------------------
//
// Copyright (c) James South.
-// Licensed under the Apache License, Version 2.0.
+// // Licensed under the Apache License, Version 2.0.
//
-//
-// Encapsulates methods to correctly parse querystring parameters.
-//
// --------------------------------------------------------------------------------------------------------------------
-
namespace ImageProcessor.Web.Helpers
{
using System;
@@ -18,7 +14,6 @@ namespace ImageProcessor.Web.Helpers
using System.Text.RegularExpressions;
using ImageProcessor.Common.Extensions;
- using ImageProcessor.Imaging;
using ImageProcessor.Web.Extensions;
///
@@ -46,21 +41,6 @@ namespace ImageProcessor.Web.Helpers
///
private static readonly Regex In100RangeRegex = new Regex(@"(-?0*(?:100|[1-9][0-9]?))", RegexOptions.Compiled);
- ///
- /// The sharpen regex.
- ///
- private static readonly Regex BlurSharpenRegex = new Regex(@"(blur|sharpen)=\d+", RegexOptions.Compiled);
-
- ///
- /// The sigma regex.
- ///
- private static readonly Regex SigmaRegex = new Regex(@"sigma(=|-)\d+(.?\d+)?", RegexOptions.Compiled);
-
- ///
- /// The threshold regex.
- ///
- private static readonly Regex ThresholdRegex = new Regex(@"threshold(=|-)\d+", RegexOptions.Compiled);
-
///
/// Returns the correct containing the angle for the given string.
///
@@ -147,100 +127,6 @@ namespace ImageProcessor.Web.Helpers
return value;
}
- ///
- /// Returns the correct for the given string.
- ///
- ///
- /// The input string containing the value to parse.
- ///
- ///
- /// The maximum size to set the Gaussian kernel to.
- ///
- ///
- /// The maximum Sigma value (standard deviation) for Gaussian function used to calculate the kernel.
- ///
- ///
- /// The maximum threshold value, which is added to each weighted sum of pixels.
- ///
- ///
- /// The correct .
- ///
- public static GaussianLayer ParseGaussianLayer(string input, int maxSize, double maxSigma, int maxThreshold)
- {
- int size = ParseBlurSharpen(input);
- double sigma = ParseSigma(input);
- int threshold = ParseThreshold(input);
-
- size = maxSize < size ? maxSize : size;
- sigma = maxSigma < sigma ? maxSigma : sigma;
- threshold = maxThreshold < threshold ? maxThreshold : threshold;
-
- return new GaussianLayer(size, sigma, threshold);
- }
-
- ///
- /// Returns the correct containing the blur value
- /// for the given string.
- ///
- ///
- /// The input string containing the value to parse.
- ///
- ///
- /// The correct for the given string.
- ///
- private static int ParseBlurSharpen(string input)
- {
- // ReSharper disable once LoopCanBeConvertedToQuery
- foreach (Match match in BlurSharpenRegex.Matches(input))
- {
- return Convert.ToInt32(match.Value.Split('=')[1]);
- }
-
- return 0;
- }
-
- ///
- /// Returns the correct containing the sigma value
- /// for the given string.
- ///
- ///
- /// The input string containing the value to parse.
- ///
- ///
- /// The correct for the given string.
- ///
- private static double ParseSigma(string input)
- {
- foreach (Match match in SigmaRegex.Matches(input))
- {
- // split on text-
- return Convert.ToDouble(match.Value.Split(new[] { '=', '-' })[1]);
- }
-
- return 1.4d;
- }
-
- ///
- /// Returns the correct containing the threshold value
- /// for the given string.
- ///
- ///
- /// The input string containing the value to parse.
- ///
- ///
- /// The correct for the given string.
- ///
- private static int ParseThreshold(string input)
- {
- // ReSharper disable once LoopCanBeConvertedToQuery
- foreach (Match match in ThresholdRegex.Matches(input))
- {
- return Convert.ToInt32(match.Value.Split(new[] { '=', '-' })[1]);
- }
-
- return 0;
- }
-
///
/// Builds a regular expression for the three main colour types.
///
diff --git a/src/ImageProcessor.Web/Helpers/QuerystringParser/ExtendedColorTypeConverter.cs b/src/ImageProcessor.Web/Helpers/QuerystringParser/ExtendedColorTypeConverter.cs
new file mode 100644
index 000000000..eec3d145c
--- /dev/null
+++ b/src/ImageProcessor.Web/Helpers/QuerystringParser/ExtendedColorTypeConverter.cs
@@ -0,0 +1,210 @@
+// --------------------------------------------------------------------------------------------------------------------
+//
+// Copyright (c) James South.
+// Licensed under the Apache License, Version 2.0.
+//
+//
+// The extended color type converter allows conversion of system and web colors.
+//
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace ImageProcessor.Web.Helpers
+{
+ using System;
+ using System.Collections;
+ using System.ComponentModel;
+ using System.Drawing;
+ using System.Globalization;
+ using System.Text;
+ using System.Text.RegularExpressions;
+
+ ///
+ /// The extended color type converter allows conversion of system and web colors.
+ ///
+ public class ExtendedColorTypeConverter : ColorConverter
+ {
+ ///
+ /// The web color regex.
+ ///
+ private static readonly Regex WebColorRegex = new Regex("([0-9a-fA-F]{3}){1,2}", RegexOptions.Compiled);
+
+ ///
+ /// The html system color table map.
+ ///
+ private static Hashtable htmlSystemColorTable;
+
+ ///
+ /// Converts the given object to the type of this converter, using the specified context and culture
+ /// information.
+ ///
+ ///
+ /// An that represents the converted value.
+ ///
+ ///
+ /// An that provides a format context.
+ ///
+ ///
+ /// The to use as the current culture.
+ ///
+ /// The to convert.
+ /// The conversion cannot be performed.
+ public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
+ {
+ string s = value as string;
+ if (s != null)
+ {
+ string colorText = s.Trim();
+ Color c = Color.Empty;
+
+ // Empty color
+ if (string.IsNullOrEmpty(colorText))
+ {
+ return c;
+ }
+
+ // Special case. HTML requires LightGrey, but System.Drawing.KnownColor has LightGray
+ if (colorText.Equals("LightGrey", StringComparison.OrdinalIgnoreCase))
+ {
+ return Color.LightGray;
+ }
+
+ // Hex based color values.
+ char hash = colorText[0];
+ if (hash == '#' || WebColorRegex.IsMatch(colorText))
+ {
+ if (hash != '#')
+ {
+ colorText = "#" + colorText;
+ }
+
+ if (colorText.Length == 7)
+ {
+ return Color.FromArgb(
+ Convert.ToInt32(colorText.Substring(1, 2), 16),
+ Convert.ToInt32(colorText.Substring(3, 2), 16),
+ Convert.ToInt32(colorText.Substring(5, 2), 16));
+ }
+
+ // Length is 4
+ string r = char.ToString(colorText[1]);
+ string g = char.ToString(colorText[2]);
+ string b = char.ToString(colorText[3]);
+
+ return Color.FromArgb(
+ Convert.ToInt32(r + r, 16),
+ Convert.ToInt32(g + g, 16),
+ Convert.ToInt32(b + b, 16));
+ }
+
+ // System color
+ if (htmlSystemColorTable == null)
+ {
+ InitializeHtmlSystemColorTable();
+ }
+
+ if (htmlSystemColorTable != null)
+ {
+ object o = htmlSystemColorTable[colorText];
+ if (o != null)
+ {
+ return (Color)o;
+ }
+ }
+ }
+
+ // ColorConverter handles all named and KnownColors
+ return base.ConvertFrom(context, culture, value);
+ }
+
+ ///
+ /// Converts the given value object to the specified type, using the specified context and culture
+ /// information.
+ ///
+ ///
+ /// An that represents the converted value.
+ ///
+ ///
+ /// An that provides a format context.
+ ///
+ ///
+ /// A . If null is passed, the current culture is assumed.
+ ///
+ /// The to convert.
+ ///
+ /// The to convert the parameter to.
+ ///
+ ///
+ /// The parameter is null.
+ ///
+ /// The conversion cannot be performed.
+ ///
+ public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
+ {
+ if (destinationType == null)
+ {
+ throw new ArgumentNullException("destinationType");
+ }
+
+ if (destinationType == typeof(string))
+ {
+ if (value != null)
+ {
+ Color color = (Color)value;
+
+ if (color == Color.Empty)
+ {
+ return string.Empty;
+ }
+
+ if (color.IsKnownColor == false)
+ {
+ // In the Web scenario, colors should be formatted in #RRGGBB notation
+ StringBuilder sb = new StringBuilder("#", 7);
+ sb.Append(color.R.ToString("X2", CultureInfo.InvariantCulture));
+ sb.Append(color.G.ToString("X2", CultureInfo.InvariantCulture));
+ sb.Append(color.B.ToString("X2", CultureInfo.InvariantCulture));
+ return sb.ToString();
+ }
+ }
+ }
+
+ return base.ConvertTo(context, culture, value, destinationType);
+ }
+
+ ///
+ /// Initializes color table mapping system colors to known colors.
+ ///
+ private static void InitializeHtmlSystemColorTable()
+ {
+ Hashtable hashTable = new Hashtable(StringComparer.OrdinalIgnoreCase);
+ hashTable["activeborder"] = Color.FromKnownColor(KnownColor.ActiveBorder);
+ hashTable["activecaption"] = Color.FromKnownColor(KnownColor.ActiveCaption);
+ hashTable["appworkspace"] = Color.FromKnownColor(KnownColor.AppWorkspace);
+ hashTable["background"] = Color.FromKnownColor(KnownColor.Desktop);
+ hashTable["buttonface"] = Color.FromKnownColor(KnownColor.Control);
+ hashTable["buttonhighlight"] = Color.FromKnownColor(KnownColor.ControlLightLight);
+ hashTable["buttonshadow"] = Color.FromKnownColor(KnownColor.ControlDark);
+ hashTable["buttontext"] = Color.FromKnownColor(KnownColor.ControlText);
+ hashTable["captiontext"] = Color.FromKnownColor(KnownColor.ActiveCaptionText);
+ hashTable["graytext"] = Color.FromKnownColor(KnownColor.GrayText);
+ hashTable["highlight"] = Color.FromKnownColor(KnownColor.Highlight);
+ hashTable["highlighttext"] = Color.FromKnownColor(KnownColor.HighlightText);
+ hashTable["inactiveborder"] = Color.FromKnownColor(KnownColor.InactiveBorder);
+ hashTable["inactivecaption"] = Color.FromKnownColor(KnownColor.InactiveCaption);
+ hashTable["inactivecaptiontext"] = Color.FromKnownColor(KnownColor.InactiveCaptionText);
+ hashTable["infobackground"] = Color.FromKnownColor(KnownColor.Info);
+ hashTable["infotext"] = Color.FromKnownColor(KnownColor.InfoText);
+ hashTable["menu"] = Color.FromKnownColor(KnownColor.Menu);
+ hashTable["menutext"] = Color.FromKnownColor(KnownColor.MenuText);
+ hashTable["scrollbar"] = Color.FromKnownColor(KnownColor.ScrollBar);
+ hashTable["threeddarkshadow"] = Color.FromKnownColor(KnownColor.ControlDarkDark);
+ hashTable["threedface"] = Color.FromKnownColor(KnownColor.Control);
+ hashTable["threedhighlight"] = Color.FromKnownColor(KnownColor.ControlLight);
+ hashTable["threedlightshadow"] = Color.FromKnownColor(KnownColor.ControlLightLight);
+ hashTable["window"] = Color.FromKnownColor(KnownColor.Window);
+ hashTable["windowframe"] = Color.FromKnownColor(KnownColor.WindowFrame);
+ hashTable["windowtext"] = Color.FromKnownColor(KnownColor.WindowText);
+ htmlSystemColorTable = hashTable;
+ }
+ }
+}
diff --git a/src/ImageProcessor.Web/Helpers/QuerystringParser/GenericArrayTypeConverter.cs b/src/ImageProcessor.Web/Helpers/QuerystringParser/GenericArrayTypeConverter.cs
new file mode 100644
index 000000000..8e8ea1063
--- /dev/null
+++ b/src/ImageProcessor.Web/Helpers/QuerystringParser/GenericArrayTypeConverter.cs
@@ -0,0 +1,48 @@
+// --------------------------------------------------------------------------------------------------------------------
+//
+// Copyright (c) James South.
+// Licensed under the Apache License, Version 2.0.
+//
+//
+// Converts the value of an string to and from a Array{T}.
+//
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace ImageProcessor.Web.Helpers
+{
+ using System.Collections.Generic;
+ using System.ComponentModel;
+ using System.Globalization;
+ using System.Linq;
+
+ ///
+ /// Converts the value of an string to and from a Array{T}.
+ ///
+ ///
+ /// The type to convert from.
+ ///
+ public class GenericArrayTypeConverter : GenericListTypeConverter
+ {
+ ///
+ /// Converts the given object to the type of this converter, using the specified context and culture
+ /// information.
+ ///
+ ///
+ /// An that represents the converted value.
+ ///
+ ///
+ /// An that provides a format context.
+ ///
+ ///
+ /// The to use as the current culture.
+ ///
+ /// The to convert.
+ /// The conversion cannot be performed.
+ public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
+ {
+ object result = base.ConvertFrom(context, culture, value);
+ IList list = result as IList;
+ return list != null ? list.ToArray() : result;
+ }
+ }
+}
diff --git a/src/ImageProcessor.Web/Helpers/QuerystringParser/GenericListTypeConverter.cs b/src/ImageProcessor.Web/Helpers/QuerystringParser/GenericListTypeConverter.cs
new file mode 100644
index 000000000..caf0bf281
--- /dev/null
+++ b/src/ImageProcessor.Web/Helpers/QuerystringParser/GenericListTypeConverter.cs
@@ -0,0 +1,161 @@
+// --------------------------------------------------------------------------------------------------------------------
+//
+// Copyright (c) James South.
+// Licensed under the Apache License, Version 2.0.
+//
+//
+// Converts the value of an string to and from a List{T}.
+//
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace ImageProcessor.Web.Helpers
+{
+ using System;
+ using System.Collections.Generic;
+ using System.ComponentModel;
+ using System.Globalization;
+ using System.Linq;
+
+ ///
+ /// Converts the value of an string to and from a List{T}.
+ ///
+ ///
+ /// The type to convert from.
+ ///
+ public class GenericListTypeConverter : TypeConverter
+ {
+ ///
+ /// The type converter.
+ ///
+ private readonly TypeConverter typeConverter;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ ///
+ /// Thrown if no converter exists for the given type.
+ ///
+ public GenericListTypeConverter()
+ {
+ Type type = typeof(T);
+ this.typeConverter = TypeDescriptor.GetConverter(type);
+ if (this.typeConverter == null)
+ {
+ throw new InvalidOperationException("No type converter exists for type " + type.FullName);
+ }
+ }
+
+ ///
+ /// Returns whether this converter can convert an object of the given type to the type of this converter,
+ /// using the specified context.
+ ///
+ ///
+ /// true if this converter can perform the conversion; otherwise, false.
+ ///
+ ///
+ /// An that provides a
+ /// format context.
+ ///
+ /// A that represents the type you want to convert from.
+ ///
+ public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
+ {
+ if (sourceType == typeof(string))
+ {
+ string[] items = this.GetStringArray(sourceType.ToString());
+ return items.Any();
+ }
+
+ return base.CanConvertFrom(context, sourceType);
+ }
+
+ ///
+ /// Converts the given object to the type of this converter, using the specified context and culture
+ /// information.
+ ///
+ ///
+ /// An that represents the converted value.
+ ///
+ ///
+ /// An that provides a format context.
+ ///
+ ///
+ /// The to use as the current culture.
+ ///
+ /// The to convert.
+ /// The conversion cannot be performed.
+ public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
+ {
+ string input = value as string;
+ if (input != null)
+ {
+ string[] items = this.GetStringArray(input);
+
+ List result = new List();
+
+ Array.ForEach(
+ items,
+ s =>
+ {
+ object item = this.typeConverter.ConvertFromInvariantString(s);
+ if (item != null)
+ {
+ result.Add((T)item);
+ }
+ });
+
+ return result;
+ }
+
+ return base.ConvertFrom(context, culture, value);
+ }
+
+ ///
+ /// Converts the given value object to the specified type, using the specified context and culture
+ /// information.
+ ///
+ ///
+ /// An that represents the converted value.
+ ///
+ ///
+ /// An that provides a format context.
+ ///
+ ///
+ /// A . If null is passed, the current culture is assumed.
+ ///
+ /// The to convert.
+ ///
+ /// The to convert the parameter to.
+ ///
+ ///
+ /// The parameter is null.
+ ///
+ /// The conversion cannot be performed.
+ ///
+ public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
+ {
+ if (destinationType == typeof(string))
+ {
+ return string.Join(",", (IList)value);
+ }
+
+ return base.ConvertTo(context, culture, value, destinationType);
+ }
+
+ ///
+ /// Splits a string by comma to return an array of string values.
+ ///
+ ///
+ /// The input string to split.
+ ///
+ ///
+ /// The array from the comma separated values.
+ ///
+ protected string[] GetStringArray(string input)
+ {
+ string[] result = input.Split(',').Select(s => s.Trim()).ToArray();
+
+ return result;
+ }
+ }
+}
diff --git a/src/ImageProcessor.Web/Helpers/QuerystringParser/QueryParamParser.cs b/src/ImageProcessor.Web/Helpers/QuerystringParser/QueryParamParser.cs
new file mode 100644
index 000000000..b8abcc898
--- /dev/null
+++ b/src/ImageProcessor.Web/Helpers/QuerystringParser/QueryParamParser.cs
@@ -0,0 +1,220 @@
+// --------------------------------------------------------------------------------------------------------------------
+//
+// Copyright (c) James South.
+// Licensed under the Apache License, Version 2.0.
+//
+//
+// The query parameter parser that converts string values to different types.
+//
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace ImageProcessor.Web.Helpers
+{
+ using System;
+ using System.Collections.Concurrent;
+ using System.Collections.Generic;
+ using System.ComponentModel;
+ using System.Drawing;
+ using System.Globalization;
+ using System.Linq.Expressions;
+
+ ///
+ /// The query parameter parser that converts string values to different types.
+ ///
+ public class QueryParamParser
+ {
+ ///
+ /// A new instance of the class.
+ /// with lazy initialization.
+ ///
+ private static readonly Lazy Lazy = new Lazy(() => new QueryParamParser());
+
+ ///
+ /// The cache for storing created default types.
+ ///
+ private static readonly ConcurrentDictionary TypeDefaultsCache = new ConcurrentDictionary();
+
+ ///
+ /// Prevents a default instance of the class from being created.
+ ///
+ private QueryParamParser()
+ {
+ this.AddColorConverters();
+ this.AddListConverters();
+ this.AddArrayConverters();
+ }
+
+ ///
+ /// Gets the current instance.
+ ///
+ public static QueryParamParser Instance
+ {
+ get
+ {
+ return Lazy.Value;
+ }
+ }
+
+ ///
+ /// Parses the given string value converting it to the given type.
+ ///
+ ///
+ /// The value to parse.
+ ///
+ ///
+ /// The to use as the current culture.
+ /// If not set will parse using
+ ///
+ ///
+ /// The to convert the string to.
+ ///
+ ///
+ /// The .
+ ///
+ public T ParseValue(string value, CultureInfo culture = null)
+ {
+ return (T)this.ParseValue(typeof(T), value, culture);
+ }
+
+ ///
+ /// Parses the given string value converting it to the given type.
+ ///
+ ///
+ /// The to convert the string to.
+ ///
+ ///
+ /// The value to parse.
+ ///
+ ///
+ /// The to use as the current culture.
+ /// If not set will parse using
+ ///
+ ///
+ /// The .
+ ///
+ public object ParseValue(Type type, string value, CultureInfo culture = null)
+ {
+ if (culture == null)
+ {
+ culture = CultureInfo.InvariantCulture;
+ }
+
+ TypeConverter converter = TypeDescriptor.GetConverter(type);
+ try
+ {
+ // ReSharper disable once AssignNullToNotNullAttribute
+ return converter.ConvertFrom(null, culture, value);
+ }
+ catch
+ {
+ // Return the default value
+ return TypeDefaultsCache.GetOrAdd(type, t => this.GetDefaultValue(type));
+ }
+ }
+
+ ///
+ /// Adds a type converter to the parser.
+ ///
+ ///
+ /// The to add a converter for.
+ ///
+ ///
+ /// The type of to add.
+ ///
+ ///
+ /// The .
+ ///
+ public TypeDescriptionProvider AddTypeConverter(Type type, Type converterType)
+ {
+ return TypeDescriptor.AddAttributes(type, new TypeConverterAttribute(converterType));
+ }
+
+ ///
+ /// Adds color converters.
+ ///
+ private void AddColorConverters()
+ {
+ this.AddTypeConverter(typeof(Color), typeof(ExtendedColorTypeConverter));
+ }
+
+ ///
+ /// Adds a selection of default list type converters.
+ ///
+ private void AddListConverters()
+ {
+ this.AddTypeConverter(typeof(List), typeof(GenericListTypeConverter));
+ this.AddTypeConverter(typeof(List), typeof(GenericListTypeConverter));
+
+ this.AddTypeConverter(typeof(List), typeof(GenericListTypeConverter));
+ this.AddTypeConverter(typeof(List), typeof(GenericListTypeConverter));
+
+ this.AddTypeConverter(typeof(List), typeof(GenericListTypeConverter));
+ this.AddTypeConverter(typeof(List), typeof(GenericListTypeConverter));
+
+ this.AddTypeConverter(typeof(List), typeof(GenericListTypeConverter));
+ this.AddTypeConverter(typeof(List), typeof(GenericListTypeConverter));
+
+ this.AddTypeConverter(typeof(List), typeof(GenericListTypeConverter));
+ this.AddTypeConverter(typeof(List), typeof(GenericListTypeConverter));
+ this.AddTypeConverter(typeof(List), typeof(GenericListTypeConverter));
+
+ this.AddTypeConverter(typeof(List), typeof(GenericListTypeConverter));
+ }
+
+ ///
+ /// Adds a selection of default array type converters.
+ ///
+ private void AddArrayConverters()
+ {
+ this.AddTypeConverter(typeof(sbyte[]), typeof(GenericArrayTypeConverter));
+ this.AddTypeConverter(typeof(byte[]), typeof(GenericArrayTypeConverter));
+
+ this.AddTypeConverter(typeof(short[]), typeof(GenericArrayTypeConverter));
+ this.AddTypeConverter(typeof(ushort[]), typeof(GenericArrayTypeConverter));
+
+ this.AddTypeConverter(typeof(int[]), typeof(GenericArrayTypeConverter));
+ this.AddTypeConverter(typeof(uint[]), typeof(GenericArrayTypeConverter));
+
+ this.AddTypeConverter(typeof(long[]), typeof(GenericArrayTypeConverter));
+ this.AddTypeConverter(typeof(ulong[]), typeof(GenericArrayTypeConverter));
+
+ this.AddTypeConverter(typeof(decimal[]), typeof(GenericArrayTypeConverter));
+ this.AddTypeConverter(typeof(float[]), typeof(GenericArrayTypeConverter));
+ this.AddTypeConverter(typeof(double[]), typeof(GenericArrayTypeConverter));
+
+ this.AddTypeConverter(typeof(string[]), typeof(GenericArrayTypeConverter));
+ }
+
+ ///
+ /// Returns the default value for the given type.
+ ///
+ ///
+ /// The to return.
+ ///
+ ///
+ /// The representing the default value.
+ ///
+ ///
+ /// Thrown if the given is null.
+ ///
+ private object GetDefaultValue(Type type)
+ {
+ // Validate parameters.
+ if (type == null)
+ {
+ throw new ArgumentNullException("type");
+ }
+
+ // We want an Func