Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions Parse.Test/ConversionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,22 @@ struct DummyValueTypeB { }

[TestMethod]
public void TestToWithConstructedNullableNonPrimitive() => Assert.ThrowsException<InvalidCastException>(() => Conversion.To<DummyValueTypeA?>(new DummyValueTypeB { }));



[TestMethod]
public void TestConvertToFloatUsingNonInvariantNumberFormat()
{
try
{
float inputValue = 1234.56f;
string jsonEncoded = Common.Internal.Json.Encode(inputValue);
float convertedValue = (float) Conversion.ConvertTo<float>(jsonEncoded);
Assert.IsTrue(inputValue == convertedValue);
}
catch (Exception ex)
{ throw ex; }
}

}
}
4 changes: 4 additions & 0 deletions Parse/Internal/ParseCorePlugins.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
using Parse.Common.Internal;
using Parse.Core.Internal;

#if DEBUG
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Parse.Test")]
#endif

namespace Parse.Core.Internal
{
public class ParseCorePlugins : IParseCorePlugins
Expand Down
8 changes: 4 additions & 4 deletions Parse/Public/ParseClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -213,19 +213,19 @@ public string MasterKey
/// <summary>
/// Authenticates this client as belonging to your application. This must be
/// called before your application can use the Parse library. The recommended
/// way is to put a call to <c>ParseFramework.Initialize</c> in your
/// way is to put a call to <c>ParseClient.Initialize</c> in your
/// Application startup.
/// </summary>
/// <param name="identifier">The Application ID provided in the Parse dashboard.
/// </param>
/// <param name="key">The .NET API Key provided in the Parse dashboard.
/// <param name="serverURI">The server URI provided in the Parse dashboard.
/// </param>
public static void Initialize(string identifier, string key) => Initialize(new Configuration { ApplicationID = identifier, Key = key });
public static void Initialize(string identifier, string serverURI) => Initialize(new Configuration { ApplicationID = identifier, ServerURI = serverURI });

/// <summary>
/// Authenticates this client as belonging to your application. This must be
/// called before your application can use the Parse library. The recommended
/// way is to put a call to <c>ParseFramework.Initialize</c> in your
/// way is to put a call to <c>ParseClient.Initialize</c> in your
/// Application startup.
/// </summary>
/// <param name="configuration">The configuration to initialize Parse with.
Expand Down
11 changes: 11 additions & 0 deletions Parse/Public/ParseObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,18 @@ internal virtual void SetDefaultValues() { }
/// <typeparam name="T">The ParseObject subclass type to register.</typeparam>
public static void RegisterSubclass<T>() where T : ParseObject, new() => SubclassingController.RegisterSubclass(typeof(T));

/// <summary>
/// Registers a custom subclass type with the Parse SDK, enabling strong-typing of those ParseObjects whenever
/// they appear. Subclasses must specify the ParseClassName attribute, have a default constructor, and properties
/// backed by ParseObject fields should have ParseFieldName attributes supplied.
/// </summary>
/// <param name="type">The ParseObject subclass type to register.</param>
public static void RegisterSubclass(Type type) { if (typeof(ParseObject).IsAssignableFrom(type)) SubclassingController.RegisterSubclass(type); }

internal static void UnregisterSubclass<T>() where T : ParseObject, new() => SubclassingController.UnregisterSubclass(typeof(T));
internal static void UnregisterSubclass(Type type) { if (typeof(ParseObject).IsAssignableFrom(type)) SubclassingController.UnregisterSubclass(type); }



/// <summary>
/// Clears any changes to this object made since the last call to <see cref="SaveAsync()"/>.
Expand Down
4 changes: 2 additions & 2 deletions Parse/Public/Utilities/Conversion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ internal static object ConvertTo<T>(object value)

if (ReflectionHelpers.IsPrimitive(typeof(T)))
{
return (T) Convert.ChangeType(value, typeof(T));
return (T) Convert.ChangeType(value, typeof(T), System.Globalization.CultureInfo.InvariantCulture);
}

if (ReflectionHelpers.IsConstructedGenericType(typeof(T)))
Expand All @@ -65,7 +65,7 @@ internal static object ConvertTo<T>(object value)
Type innerType = ReflectionHelpers.GetGenericTypeArguments(typeof(T))[0];
if (ReflectionHelpers.IsPrimitive(innerType))
{
return (T) Convert.ChangeType(value, innerType);
return (T) Convert.ChangeType(value, innerType, System.Globalization.CultureInfo.InvariantCulture);
}
}
Type listType = GetInterfaceType(value.GetType(), typeof(IList<>));
Expand Down