Skip to content

Commit cab92f6

Browse files
committed
Add namespaced newtonsoft dll and switch using directives
1 parent a22da9b commit cab92f6

14 files changed

+11518
-25
lines changed

Runtime/Client/GetRequests.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,24 @@
11
using System.Collections.Generic;
2+
#if USE_LOOTLOCKER_ZERODEPJSON
23
using LootLocker.ZeroDepJson;
4+
#endif
35

46
namespace LootLocker.Requests
57
{
68
public class LootLockerGetRequest
79
{
10+
11+
#if USE_LOOTLOCKER_ZERODEPJSON
812
[Json(IgnoreWhenSerializing = true, IgnoreWhenDeserializing = true)]
913
public List<string> getRequests = new List<string>();
14+
#else
15+
public List<string> getRequests = new List<string>();
16+
17+
public bool ShouldSerializegetRequests()
18+
{
19+
// don't serialize the getRequests property.
20+
return false;
21+
}
22+
#endif
1023
}
1124
}

Runtime/Client/LootLockerBaseServerAPI.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
using System;
66
using System.Text;
77
using System.Net;
8+
#if !USE_LOOTLOCKER_ZERODEPJSON
9+
using LLlibs.Newtonsoft.Json;
10+
using LLlibs.Newtonsoft.Json.Linq;
11+
#endif
812
using LootLocker.Requests;
913

1014
namespace LootLocker.LootLockerEnums
@@ -362,11 +366,13 @@ public ObfuscationDetails(string key, char replacementChar = '*', int visibleCha
362366
new ObfuscationDetails("token")
363367
};
364368

365-
//TODO: Fix this json usage
366369
private static string ObfuscateJsonStringForLogging(string json)
367370
{
371+
#if USE_LOOTLOCKER_ZERODEPJSON
372+
//TODO: Fix this json usage
368373
return json;
369-
/*if (string.IsNullOrEmpty(json))
374+
#else
375+
if (string.IsNullOrEmpty(json))
370376
{
371377
return json;
372378
}
@@ -430,7 +436,8 @@ private static string ObfuscateJsonStringForLogging(string json)
430436
}
431437
}
432438

433-
return LootLockerJson.SerializeObject(jsonObject);*/
439+
return LootLockerJson.SerializeObject(jsonObject);
440+
#endif
434441
}
435442

436443
string BuildURL(string endpoint, Dictionary<string, string> queryParams = null)

Runtime/Client/LootLockerServerRequest.cs

Lines changed: 66 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22
using UnityEngine;
33
using System;
44
using LootLocker.LootLockerEnums;
5+
#if USE_LOOTLOCKER_ZERODEPJSON
56
using LootLocker.ZeroDepJson;
7+
#else //USE_LOOTLOCKER_ZERODEPJSON
8+
using LLlibs.Newtonsoft.Json.Serialization;
9+
using LLlibs.Newtonsoft.Json;
10+
#endif
611
#if UNITY_EDITOR
712
using UnityEditor;
813
#endif
@@ -13,20 +18,61 @@ namespace LootLocker
1318

1419
public static class LootLockerJsonSettings
1520
{
21+
#if USE_LOOTLOCKER_ZERODEPJSON
1622
public static readonly JsonOptions Default = new JsonOptions(JsonSerializationOptions.Default & ~JsonSerializationOptions.SkipGetOnly);
23+
#else //USE_LOOTLOCKER_ZERODEPJSON
24+
public static readonly JsonSerializerSettings Default = new JsonSerializerSettings
25+
{
26+
ContractResolver = new DefaultContractResolver { NamingStrategy = new SnakeCaseNamingStrategy() },
27+
Formatting = Formatting.None
28+
};
29+
#endif
1730
}
1831

1932
public static class LootLockerJson
2033
{
21-
public static string SerializeObject(object obj, JsonOptions options = null)
34+
#if USE_LOOTLOCKER_ZERODEPJSON
35+
public static string SerializeObject(object obj)
36+
{
37+
return SerializeObject(obj, LootLockerJsonSettings.Default);
38+
}
39+
40+
public static string SerializeObject(object obj, JsonOptions options)
2241
{
2342
return Json.Serialize(obj, options ?? LootLockerJsonSettings.Default);
2443
}
2544

26-
public static T DeserializeObject<T>(string json, JsonOptions options = null)
45+
public static T DeserializeObject<T>(string json)
46+
{
47+
return DeserializeObject<T>(json, LootLockerJsonSettings.Default);
48+
}
49+
50+
public static T DeserializeObject<T>(string json, JsonOptions options)
2751
{
2852
return Json.Deserialize<T>(json, options ?? LootLockerJsonSettings.Default);
2953
}
54+
#else //USE_LOOTLOCKER_ZERODEPJSON
55+
public static string SerializeObject(object obj)
56+
{
57+
return SerializeObject(obj, LootLockerJsonSettings.Default);
58+
}
59+
60+
public static string SerializeObject(object obj, JsonSerializerSettings settings)
61+
{
62+
return JsonConvert.SerializeObject(obj, settings ?? LootLockerJsonSettings.Default);
63+
}
64+
65+
public static T DeserializeObject<T>(string json)
66+
{
67+
return DeserializeObject<T>(json, LootLockerJsonSettings.Default);
68+
}
69+
70+
71+
public static T DeserializeObject<T>(string json, JsonSerializerSettings settings)
72+
{
73+
return JsonConvert.DeserializeObject<T>(json, settings ?? LootLockerJsonSettings.Default);
74+
}
75+
#endif
3076
}
3177

3278
[Serializable]
@@ -81,13 +127,25 @@ public class LootLockerResponse
81127
/// </summary>
82128
public string EventId { get; set; }
83129

84-
public static void Deserialize<T>(Action<T> onComplete, LootLockerResponse serverResponse, JsonOptions options = null)
130+
public static void Deserialize<T>(Action<T> onComplete, LootLockerResponse serverResponse,
131+
#if USE_LOOTLOCKER_ZERODEPJSON
132+
JsonOptions options = null
133+
#else //USE_LOOTLOCKER_ZERODEPJSON
134+
JsonSerializerSettings options = null
135+
#endif
136+
)
85137
where T : LootLockerResponse, new()
86138
{
87139
onComplete?.Invoke(Deserialize<T>(serverResponse, options));
88140
}
89141

90-
public static T Deserialize<T>(LootLockerResponse serverResponse, JsonOptions options = null)
142+
public static T Deserialize<T>(LootLockerResponse serverResponse,
143+
#if USE_LOOTLOCKER_ZERODEPJSON
144+
JsonOptions options = null
145+
#else //USE_LOOTLOCKER_ZERODEPJSON
146+
JsonSerializerSettings options = null
147+
#endif
148+
)
91149
where T : LootLockerResponse, new()
92150
{
93151
if (serverResponse == null)
@@ -314,12 +372,12 @@ public struct LootLockerServerRequest
314372
{
315373
public string endpoint { get; set; }
316374
public LootLockerHTTPMethod httpMethod { get; set; }
317-
public Dictionary<string, object> payload;
375+
public Dictionary<string, object> payload { get; set; }
318376
public string jsonPayload { get; set; }
319377
public byte[] upload { get; set; }
320378
public string uploadName { get; set; }
321379
public string uploadType { get; set; }
322-
public LootLocker.LootLockerEnums.LootLockerCallerRole adminCall;
380+
public LootLocker.LootLockerEnums.LootLockerCallerRole adminCall { get; set; }
323381
public WWWForm form { get; set; }
324382

325383
/// <summary>
@@ -413,9 +471,9 @@ public static void UploadFile(string endPoint, LootLockerHTTPMethod httpMethod,
413471
Dictionary<string, string> headers = new Dictionary<string, string>();
414472
if (file.Length == 0)
415473
{
416-
#if UNITY_EDITOR
474+
#if UNITY_EDITOR
417475
LootLockerLogger.GetForLogLevel(LootLockerLogger.LogLevel.Error)("File content is empty, not allowed.");
418-
#endif
476+
#endif
419477
onComplete?.Invoke(LootLockerResponseFactory.Error<LootLockerResponse>("File content is empty, not allowed."));
420478
return;
421479
}

Runtime/Game/Requests/AssetRequest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public class LootLockerVariation_Info
6060
public class LootLockerAssetRequest : LootLockerResponse
6161
{
6262
public int count { get; set; }
63-
public static int lastId;
63+
public static int lastId { get; set; }
6464

6565
public static void ResetAssetCalls()
6666
{

Runtime/Game/Requests/CharacterRequest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class LootLockerCharacter_Types
3434
public int id { get; set; }
3535
public bool is_default { get; set; }
3636
public string name { get; set; }
37-
public LootLockerStorage [] storage;
37+
public LootLockerStorage[] storage { get; set; }
3838
}
3939

4040

Runtime/Game/Requests/LeaderboardRequest.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ public class LootLockerGetMemberRankRequest
9090
public class LootLockerGetScoreListRequest : LootLockerGetRequests
9191
{
9292
public string leaderboardKey { get; set; }
93-
public static int? nextCursor;
94-
public static int? prevCursor;
93+
public static int? nextCursor { get; set; }
94+
public static int? prevCursor { get; set; }
9595

9696
public static void Reset()
9797
{
@@ -103,8 +103,8 @@ public static void Reset()
103103
public class LootLockerGetAllMemberRanksRequest : LootLockerGetRequests
104104
{
105105
public int member_id { get; set; }
106-
public static int? nextCursor;
107-
public static int? prevCursor;
106+
public static int? nextCursor { get; set; }
107+
public static int? prevCursor { get; set; }
108108

109109
public static void Reset()
110110
{

Runtime/Game/Requests/PlayerRequest.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
using System;
2-
using LootLocker.Requests;
2+
using LootLocker.Requests;
3+
#if USE_LOOTLOCKER_ZERODEPJSON
34
using LootLocker.ZeroDepJson;
5+
#else
6+
using LLlibs.Newtonsoft.Json;
7+
#endif
48

59
namespace LootLocker.Requests
610
{
@@ -202,8 +206,13 @@ public class LootLockerPlayerFile : LootLockerResponse
202206
public string revision_id { get; set; }
203207
public string name { get; set; }
204208
public int size { get; set; }
205-
public string purpose { get; set; }
209+
public string purpose { get; set; }
210+
211+
#if USE_LOOTLOCKER_ZERODEPJSON
206212
[Json(Name = "public")]
213+
#else
214+
[JsonProperty("public")]
215+
#endif
207216
public bool is_public { get; set; }
208217
public string url { get; set; }
209218
public DateTime url_expires_at { get; set; }

Runtime/Libraries.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Runtime/Libraries/Newtonsoft.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Binary file not shown.

0 commit comments

Comments
 (0)