-Added non-generic JToken.ToObject methods

-Added byte, char, Guid, TimeSpan and Uri explicit conversion operators to JToken
-Fixed globalization warnings
This commit is contained in:
James Newton-King
2012-11-18 21:10:01 +13:00
parent e3be3e43db
commit a8249e38df
5 changed files with 357 additions and 15 deletions
+11 -6
View File
@@ -222,6 +222,15 @@ namespace Newtonsoft.Json.Utilities
#endif
}
public static TimeSpan ParseTimeSpan(string input)
{
#if !(NET35 || NET20 || PORTABLE || WINDOWS_PHONE)
return TimeSpan.Parse((string) input, CultureInfo.InvariantCulture);
#else
return TimeSpan.Parse((string)input);
#endif
}
internal struct TypeConvertKey : IEquatable<TypeConvertKey>
{
private readonly Type _initialType;
@@ -331,12 +340,8 @@ namespace Newtonsoft.Json.Utilities
return new Guid((string) initialValue);
if (targetType == typeof (Uri))
return new Uri((string) initialValue, UriKind.RelativeOrAbsolute);
if (targetType == typeof (TimeSpan))
#if !(NET35 || NET20 || PORTABLE || WINDOWS_PHONE)
return TimeSpan.Parse((string) initialValue, CultureInfo.InvariantCulture);
#else
return TimeSpan.Parse((string)initialValue);
#endif
if (targetType == typeof(TimeSpan))
return ParseTimeSpan((string) initialValue);
}
#if !(NETFX_CORE || PORTABLE)