Skip to content

Allow custom server URLs to be set and used via ParseClient.Configuration. #147

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 6, 2016
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
2 changes: 1 addition & 1 deletion Parse/Internal/Command/ParseCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public ParseCommand(string relativeUri,
IList<KeyValuePair<string, string>> headers = null,
Stream stream = null,
string contentType = null) {
Uri = new Uri(ParseClient.HostName, relativeUri);
Uri = new Uri(new Uri(ParseClient.CurrentConfiguration.Server), relativeUri);
Method = method;
Data = stream;

Expand Down
16 changes: 11 additions & 5 deletions Parse/Public/ParseClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,18 @@ public static partial class ParseClient {
/// <summary>
/// Represents the configuration of the Parse SDK.
/// </summary>
public struct Configuration {
public struct Configuration {
/// <summary>
/// The Parse.com application ID of your app.
/// </summary>
public String ApplicationId { get; set; }
public String ApplicationId { get; set; }

/// <summary>
/// The Parse.com API server to connect to.
///
/// Only needs to be set if you're using another server than https://api.parse.com/1.
/// </summary>
public String Server { get; set; }

/// <summary>
/// The Parse.com .NET key for your app.
Expand Down Expand Up @@ -78,7 +85,6 @@ private static Type GetParseType(string name) {
/// The current configuration that parse has been initialized with.
/// </summary>
public static Configuration CurrentConfiguration { get; internal set; }
internal static Uri HostName { get; set; }
internal static string MasterKey { get; set; }

internal static Version Version {
Expand Down Expand Up @@ -121,8 +127,8 @@ public static void Initialize(string applicationId, string dotnetKey) {
/// <param name="configuration">The configuration to initialize Parse with.
/// </param>
public static void Initialize(Configuration configuration) {
lock (mutex) {
HostName = HostName ?? new Uri("https://api.parse.com/1/");
lock (mutex) {
configuration.Server = configuration.Server ?? "https://api.parse.com/1/";
CurrentConfiguration = configuration;

ParseObject.RegisterSubclass<ParseUser>();
Expand Down
10 changes: 4 additions & 6 deletions ParseTest.Unit/AnalyticsControllerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@ namespace ParseTest {
public class AnalyticsControllerTests {
[SetUp]
public void SetUp() {
ParseClient.HostName = new Uri("http://api.parse.local/1/");
}

[TearDown]
public void TearDown() {
ParseClient.HostName = null;
ParseClient.Initialize(new ParseClient.Configuration {
ApplicationId = "",
WindowsKey = ""
});
}

[Test]
Expand Down
10 changes: 4 additions & 6 deletions ParseTest.Unit/CloudControllerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@ namespace ParseTest {
public class CloudControllerTests {
[SetUp]
public void SetUp() {
ParseClient.HostName = new Uri("http://parse.com");
}

[TearDown]
public void TearDown() {
ParseClient.HostName = null;
ParseClient.Initialize(new ParseClient.Configuration {
ApplicationId = "",
WindowsKey = ""
});
}

[Test]
Expand Down
6 changes: 4 additions & 2 deletions ParseTest.Unit/CommandTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ namespace ParseTest {
public class CommandTests {
[SetUp]
public void SetUp() {
ParseClient.HostName = new Uri("http://api.parse.local/1/");
ParseClient.Initialize(new ParseClient.Configuration {
ApplicationId = "",
WindowsKey = ""
});
}

[TearDown]
public void TearDown() {
ParseClient.HostName = null;
ParseClient.ApplicationSettings.Clear();
}

Expand Down
10 changes: 4 additions & 6 deletions ParseTest.Unit/FileControllerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@ namespace ParseTest {
public class FileControllerTests {
[SetUp]
public void SetUp() {
ParseClient.HostName = new Uri("http://parse.com");
}

[TearDown]
public void TearDown() {
ParseClient.HostName = null;
ParseClient.Initialize(new ParseClient.Configuration {
ApplicationId = "",
WindowsKey = ""
});
}

[Test]
Expand Down
10 changes: 4 additions & 6 deletions ParseTest.Unit/ObjectControllerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@ namespace ParseTest {
public class ObjectControllerTests {
[SetUp]
public void SetUp() {
ParseClient.HostName = new Uri("http://api.parse.local/1/");
}

[TearDown]
public void TearDown() {
ParseClient.HostName = null;
ParseClient.Initialize(new ParseClient.Configuration {
ApplicationId = "",
WindowsKey = ""
});
}

[Test]
Expand Down
10 changes: 4 additions & 6 deletions ParseTest.Unit/SessionControllerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@ namespace ParseTest {
public class SessionControllerTests {
[SetUp]
public void SetUp() {
ParseClient.HostName = new Uri("http://api.parse.local/1/");
}

[TearDown]
public void TearDown() {
ParseClient.HostName = null;
ParseClient.Initialize(new ParseClient.Configuration {
ApplicationId = "",
WindowsKey = ""
});
}

[Test]
Expand Down
10 changes: 4 additions & 6 deletions ParseTest.Unit/UserControllerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@ namespace ParseTest {
public class UserControllerTests {
[SetUp]
public void SetUp() {
ParseClient.HostName = new Uri("http://api.parse.local/1/");
}

[TearDown]
public void TearDown() {
ParseClient.HostName = null;
ParseClient.Initialize(new ParseClient.Configuration {
ApplicationId = "",
WindowsKey = ""
});
}

[Test]
Expand Down