Fixed #5141 Retrieve & Store doesn't support char

This commit is contained in:
Sergio Navarro
2015-07-07 19:42:06 +02:00
parent 89c5b2f7de
commit d805c7773d

View File

@@ -153,7 +153,7 @@ namespace Orchard.ContentManagement {
/// <returns>The string representation of the value.</returns> /// <returns>The string representation of the value.</returns>
public static string ToString<T>(T value) { public static string ToString<T>(T value) {
var type = typeof(T); var type = typeof(T);
if (type == typeof(string)) { if (type == typeof(string) || type == typeof(char)) {
return Convert.ToString(value); return Convert.ToString(value);
} }
if ((!type.IsValueType || Nullable.GetUnderlyingType(type) != null) && if ((!type.IsValueType || Nullable.GetUnderlyingType(type) != null) &&
@@ -250,6 +250,9 @@ namespace Orchard.ContentManagement {
if (type == typeof(double)) return (T)(object)double.NegativeInfinity; if (type == typeof(double)) return (T)(object)double.NegativeInfinity;
throw new NotSupportedException(String.Format("Infinity not supported for type {0}", type.Name)); throw new NotSupportedException(String.Format("Infinity not supported for type {0}", type.Name));
} }
if (type == typeof(char) || type == typeof(char?)) {
return (T)(object)char.Parse(value);
}
if (type == typeof(int) || type == typeof(int?)) { if (type == typeof(int) || type == typeof(int?)) {
return (T)(object)int.Parse(value, CultureInfo.InvariantCulture); return (T)(object)int.Parse(value, CultureInfo.InvariantCulture);
} }
@@ -356,4 +359,4 @@ namespace Orchard.ContentManagement {
} }
} }
} }
} }