Merge pull request #5486 from jersiovic/patch-4

Issue #5141 Retrieve/Store methods from InfoSet doesn't support char type
This commit is contained in:
Sébastien Ros
2015-07-09 13:00:10 -07:00

View File

@@ -153,7 +153,7 @@ namespace Orchard.ContentManagement {
/// <returns>The string representation of the value.</returns>
public static string ToString<T>(T value) {
var type = typeof(T);
if (type == typeof(string)) {
if (type == typeof(string) || type == typeof(char)) {
return Convert.ToString(value);
}
if ((!type.IsValueType || Nullable.GetUnderlyingType(type) != null) &&
@@ -250,6 +250,9 @@ namespace Orchard.ContentManagement {
if (type == typeof(double)) return (T)(object)double.NegativeInfinity;
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?)) {
return (T)(object)int.Parse(value, CultureInfo.InvariantCulture);
}
@@ -356,4 +359,4 @@ namespace Orchard.ContentManagement {
}
}
}
}
}