Skip to content

Commit 7458e03

Browse files
Merge pull request #147 from ParsePlatform/richardross.serverurl.configuration
Allow custom server URLs to be set and used via ParseClient.Configuration.
2 parents 32ba847 + 329ceca commit 7458e03

File tree

9 files changed

+40
-44
lines changed

9 files changed

+40
-44
lines changed

Parse/Internal/Command/ParseCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public ParseCommand(string relativeUri,
4646
IList<KeyValuePair<string, string>> headers = null,
4747
Stream stream = null,
4848
string contentType = null) {
49-
Uri = new Uri(ParseClient.HostName, relativeUri);
49+
Uri = new Uri(new Uri(ParseClient.CurrentConfiguration.Server), relativeUri);
5050
Method = method;
5151
Data = stream;
5252

Parse/Public/ParseClient.cs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,18 @@ public static partial class ParseClient {
3131
/// <summary>
3232
/// Represents the configuration of the Parse SDK.
3333
/// </summary>
34-
public struct Configuration {
34+
public struct Configuration {
3535
/// <summary>
3636
/// The Parse.com application ID of your app.
3737
/// </summary>
38-
public String ApplicationId { get; set; }
38+
public String ApplicationId { get; set; }
39+
40+
/// <summary>
41+
/// The Parse.com API server to connect to.
42+
///
43+
/// Only needs to be set if you're using another server than https://api.parse.com/1.
44+
/// </summary>
45+
public String Server { get; set; }
3946

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

8490
internal static Version Version {
@@ -121,8 +127,8 @@ public static void Initialize(string applicationId, string dotnetKey) {
121127
/// <param name="configuration">The configuration to initialize Parse with.
122128
/// </param>
123129
public static void Initialize(Configuration configuration) {
124-
lock (mutex) {
125-
HostName = HostName ?? new Uri("https://api.parse.com/1/");
130+
lock (mutex) {
131+
configuration.Server = configuration.Server ?? "https://api.parse.com/1/";
126132
CurrentConfiguration = configuration;
127133

128134
ParseObject.RegisterSubclass<ParseUser>();

ParseTest.Unit/AnalyticsControllerTests.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,10 @@ namespace ParseTest {
1414
public class AnalyticsControllerTests {
1515
[SetUp]
1616
public void SetUp() {
17-
ParseClient.HostName = new Uri("http://api.parse.local/1/");
18-
}
19-
20-
[TearDown]
21-
public void TearDown() {
22-
ParseClient.HostName = null;
17+
ParseClient.Initialize(new ParseClient.Configuration {
18+
ApplicationId = "",
19+
WindowsKey = ""
20+
});
2321
}
2422

2523
[Test]

ParseTest.Unit/CloudControllerTests.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,10 @@ namespace ParseTest {
1414
public class CloudControllerTests {
1515
[SetUp]
1616
public void SetUp() {
17-
ParseClient.HostName = new Uri("http://parse.com");
18-
}
19-
20-
[TearDown]
21-
public void TearDown() {
22-
ParseClient.HostName = null;
17+
ParseClient.Initialize(new ParseClient.Configuration {
18+
ApplicationId = "",
19+
WindowsKey = ""
20+
});
2321
}
2422

2523
[Test]

ParseTest.Unit/CommandTests.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@ namespace ParseTest {
1515
public class CommandTests {
1616
[SetUp]
1717
public void SetUp() {
18-
ParseClient.HostName = new Uri("http://api.parse.local/1/");
18+
ParseClient.Initialize(new ParseClient.Configuration {
19+
ApplicationId = "",
20+
WindowsKey = ""
21+
});
1922
}
2023

2124
[TearDown]
2225
public void TearDown() {
23-
ParseClient.HostName = null;
2426
ParseClient.ApplicationSettings.Clear();
2527
}
2628

ParseTest.Unit/FileControllerTests.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,10 @@ namespace ParseTest {
1515
public class FileControllerTests {
1616
[SetUp]
1717
public void SetUp() {
18-
ParseClient.HostName = new Uri("http://parse.com");
19-
}
20-
21-
[TearDown]
22-
public void TearDown() {
23-
ParseClient.HostName = null;
18+
ParseClient.Initialize(new ParseClient.Configuration {
19+
ApplicationId = "",
20+
WindowsKey = ""
21+
});
2422
}
2523

2624
[Test]

ParseTest.Unit/ObjectControllerTests.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,10 @@ namespace ParseTest {
1515
public class ObjectControllerTests {
1616
[SetUp]
1717
public void SetUp() {
18-
ParseClient.HostName = new Uri("http://api.parse.local/1/");
19-
}
20-
21-
[TearDown]
22-
public void TearDown() {
23-
ParseClient.HostName = null;
18+
ParseClient.Initialize(new ParseClient.Configuration {
19+
ApplicationId = "",
20+
WindowsKey = ""
21+
});
2422
}
2523

2624
[Test]

ParseTest.Unit/SessionControllerTests.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,10 @@ namespace ParseTest {
1515
public class SessionControllerTests {
1616
[SetUp]
1717
public void SetUp() {
18-
ParseClient.HostName = new Uri("http://api.parse.local/1/");
19-
}
20-
21-
[TearDown]
22-
public void TearDown() {
23-
ParseClient.HostName = null;
18+
ParseClient.Initialize(new ParseClient.Configuration {
19+
ApplicationId = "",
20+
WindowsKey = ""
21+
});
2422
}
2523

2624
[Test]

ParseTest.Unit/UserControllerTests.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,10 @@ namespace ParseTest {
1414
public class UserControllerTests {
1515
[SetUp]
1616
public void SetUp() {
17-
ParseClient.HostName = new Uri("http://api.parse.local/1/");
18-
}
19-
20-
[TearDown]
21-
public void TearDown() {
22-
ParseClient.HostName = null;
17+
ParseClient.Initialize(new ParseClient.Configuration {
18+
ApplicationId = "",
19+
WindowsKey = ""
20+
});
2321
}
2422

2523
[Test]

0 commit comments

Comments
 (0)