com.xmobitea.changx.gn-unity 2.0.3 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Editor/GNServerSettingsEditor.cs +16 -300
- package/Runtime/Common/GNArray.cs +387 -302
- package/Runtime/Common/GNArray.cs.meta +11 -11
- package/Runtime/Common/GNData.cs +61 -48
- package/Runtime/Common/GNData.cs.meta +11 -11
- package/Runtime/Common/GNHashtable.cs +404 -241
- package/Runtime/Common/GNHashtable.cs.meta +11 -11
- package/Runtime/Common/IGNData.cs +20 -11
- package/Runtime/Common/IGNData.cs.meta +11 -11
- package/Runtime/Common.meta +8 -8
- package/Runtime/Config/GNServerSettings.cs +136 -92
- package/Runtime/Config/GNServerSettings.cs.meta +11 -11
- package/Runtime/Config.meta +8 -8
- package/Runtime/Constant/Commands.cs +82 -19
- package/Runtime/Constant/Commands.cs.meta +11 -11
- package/Runtime/Constant/EnumType/FriendStatus.cs +12 -12
- package/Runtime/Constant/EnumType/FriendStatus.cs.meta +11 -11
- package/Runtime/Constant/EnumType/GoogleLoginType.cs +5 -5
- package/Runtime/Constant/EnumType/GoogleLoginType.cs.meta +11 -11
- package/Runtime/Constant/EnumType/GroupStatus.cs +7 -7
- package/Runtime/Constant/EnumType/GroupStatus.cs.meta +11 -11
- package/Runtime/Constant/EnumType/InvalidMemberType.cs +23 -23
- package/Runtime/Constant/EnumType/InvalidMemberType.cs.meta +11 -11
- package/Runtime/Constant/EnumType/ItemType.cs +5 -5
- package/Runtime/Constant/EnumType/ItemType.cs.meta +11 -11
- package/Runtime/Constant/EnumType/MatchmakingMemberStatus.cs +6 -6
- package/Runtime/Constant/EnumType/MatchmakingMemberStatus.cs.meta +11 -11
- package/Runtime/Constant/EnumType/MatchmakingTicketStatus.cs +2 -2
- package/Runtime/Constant/EnumType/MatchmakingTicketStatus.cs.meta +11 -11
- package/Runtime/Constant/EnumType/OwnerType.cs +3 -2
- package/Runtime/Constant/EnumType/OwnerType.cs.meta +11 -11
- package/Runtime/Constant/EnumType/PermissionDataItem.cs +10 -10
- package/Runtime/Constant/EnumType/PermissionDataItem.cs.meta +11 -11
- package/Runtime/Constant/EnumType/PushPlatformType.cs +10 -0
- package/Runtime/Constant/EnumType/PushPlatformType.cs.meta +11 -0
- package/Runtime/Constant/EnumType/RequestRole.cs +11 -11
- package/Runtime/Constant/EnumType/RequestRole.cs.meta +7 -7
- package/Runtime/Constant/EnumType/RequestType.cs +20 -19
- package/Runtime/Constant/EnumType/RequestType.cs.meta +11 -11
- package/Runtime/Constant/EnumType/StoreReceiveType.cs +13 -0
- package/Runtime/Constant/EnumType/StoreReceiveType.cs.meta +11 -0
- package/Runtime/Constant/EnumType.meta +8 -8
- package/Runtime/Constant/ErrorCode/GNErrorCode.cs +53 -48
- package/Runtime/Constant/ErrorCode/GNErrorCode.cs.meta +7 -7
- package/Runtime/Constant/ErrorCode.meta +8 -8
- package/Runtime/Constant/EventCode.cs +43 -16
- package/Runtime/Constant/EventCode.cs.meta +11 -11
- package/Runtime/Constant/OperationCode.cs +249 -211
- package/Runtime/Constant/OperationCode.cs.meta +11 -11
- package/Runtime/Constant/ParameterCode/GNParameterCode.cs +614 -466
- package/Runtime/Constant/ParameterCode/GNParameterCode.cs.meta +11 -11
- package/Runtime/Constant/ParameterCode/ParameterCode.cs +12 -12
- package/Runtime/Constant/ParameterCode/ParameterCode.cs.meta +11 -11
- package/Runtime/Constant/ParameterCode.meta +8 -8
- package/Runtime/Constant/ReturnCode.cs +73 -25
- package/Runtime/Constant/ReturnCode.cs.meta +11 -11
- package/Runtime/Constant.meta +8 -8
- package/Runtime/Entity/DataMember.cs +342 -124
- package/Runtime/Entity/DataMember.cs.meta +11 -11
- package/Runtime/Entity/GNMetadata.cs +72 -27
- package/Runtime/Entity/GNMetadata.cs.meta +11 -11
- package/Runtime/Entity/InvalidMember.cs +52 -33
- package/Runtime/Entity/InvalidMember.cs.meta +11 -11
- package/Runtime/Entity/Models/AuthenticateModels.cs +251 -207
- package/Runtime/Entity/Models/AuthenticateModels.cs.meta +11 -11
- package/Runtime/Entity/Models/AuthenticateRequestModels.cs +153 -131
- package/Runtime/Entity/Models/AuthenticateRequestModels.cs.meta +11 -11
- package/Runtime/Entity/Models/AuthenticateResponseModels.cs +61 -51
- package/Runtime/Entity/Models/AuthenticateResponseModels.cs.meta +11 -11
- package/Runtime/Entity/Models/CharacterPlayerModels.cs +985 -849
- package/Runtime/Entity/Models/CharacterPlayerModels.cs.meta +11 -11
- package/Runtime/Entity/Models/CharacterPlayerRequestModels.cs +957 -885
- package/Runtime/Entity/Models/CharacterPlayerRequestModels.cs.meta +11 -11
- package/Runtime/Entity/Models/CharacterPlayerResponseModels.cs +165 -150
- package/Runtime/Entity/Models/CharacterPlayerResponseModels.cs.meta +11 -11
- package/Runtime/Entity/Models/CloudScriptModels.cs +185 -0
- package/Runtime/Entity/Models/CloudScriptModels.cs.meta +11 -0
- package/Runtime/Entity/Models/CloudScriptRequestModels.cs +134 -0
- package/Runtime/Entity/Models/CloudScriptRequestModels.cs.meta +11 -0
- package/Runtime/Entity/Models/CloudScriptResponseModels.cs +34 -0
- package/Runtime/Entity/Models/CloudScriptResponseModels.cs.meta +11 -0
- package/Runtime/Entity/Models/ContentModels.cs +150 -153
- package/Runtime/Entity/Models/ContentModels.cs.meta +11 -11
- package/Runtime/Entity/Models/ContentRequestModels.cs +129 -129
- package/Runtime/Entity/Models/ContentRequestModels.cs.meta +11 -11
- package/Runtime/Entity/Models/ContentResponseModels.cs +24 -24
- package/Runtime/Entity/Models/ContentResponseModels.cs.meta +11 -11
- package/Runtime/Entity/Models/DashboardModels.cs +1684 -1156
- package/Runtime/Entity/Models/DashboardModels.cs.meta +11 -11
- package/Runtime/Entity/Models/DashboardRequestModels.cs +220 -147
- package/Runtime/Entity/Models/DashboardRequestModels.cs.meta +11 -11
- package/Runtime/Entity/Models/DashboardResponseModels.cs +92 -57
- package/Runtime/Entity/Models/DashboardResponseModels.cs.meta +11 -11
- package/Runtime/Entity/Models/GamePlayerModels.cs +1073 -933
- package/Runtime/Entity/Models/GamePlayerModels.cs.meta +11 -11
- package/Runtime/Entity/Models/GamePlayerRequestModels.cs +939 -867
- package/Runtime/Entity/Models/GamePlayerRequestModels.cs.meta +11 -11
- package/Runtime/Entity/Models/GamePlayerResponseModels.cs +162 -147
- package/Runtime/Entity/Models/GamePlayerResponseModels.cs.meta +11 -11
- package/Runtime/Entity/Models/GenericModels.cs +102 -102
- package/Runtime/Entity/Models/GenericModels.cs.meta +11 -11
- package/Runtime/Entity/Models/GroupModels.cs +812 -676
- package/Runtime/Entity/Models/GroupModels.cs.meta +11 -11
- package/Runtime/Entity/Models/GroupRequestModels.cs +741 -669
- package/Runtime/Entity/Models/GroupRequestModels.cs.meta +11 -11
- package/Runtime/Entity/Models/GroupResponseModels.cs +129 -114
- package/Runtime/Entity/Models/GroupResponseModels.cs.meta +11 -11
- package/Runtime/Entity/Models/InventoryModels.cs +667 -558
- package/Runtime/Entity/Models/InventoryModels.cs.meta +11 -11
- package/Runtime/Entity/Models/InventoryRequestModels.cs +626 -579
- package/Runtime/Entity/Models/InventoryRequestModels.cs.meta +11 -11
- package/Runtime/Entity/Models/InventoryResponseModels.cs +109 -99
- package/Runtime/Entity/Models/InventoryResponseModels.cs.meta +11 -11
- package/Runtime/Entity/Models/MasterPlayerModels.cs +1882 -1340
- package/Runtime/Entity/Models/MasterPlayerModels.cs.meta +11 -11
- package/Runtime/Entity/Models/MasterPlayerRequestModels.cs +1643 -1253
- package/Runtime/Entity/Models/MasterPlayerRequestModels.cs.meta +11 -11
- package/Runtime/Entity/Models/MasterPlayerResponseModels.cs +293 -213
- package/Runtime/Entity/Models/MasterPlayerResponseModels.cs.meta +11 -11
- package/Runtime/Entity/Models/MultiplayerModels.cs +293 -223
- package/Runtime/Entity/Models/MultiplayerModels.cs.meta +11 -11
- package/Runtime/Entity/Models/MultiplayerRequestModels.cs +199 -149
- package/Runtime/Entity/Models/MultiplayerRequestModels.cs.meta +11 -11
- package/Runtime/Entity/Models/MultiplayerResponseModels.cs +59 -49
- package/Runtime/Entity/Models/MultiplayerResponseModels.cs.meta +11 -11
- package/Runtime/Entity/Models/StoreInventoryModels.cs +514 -323
- package/Runtime/Entity/Models/StoreInventoryModels.cs.meta +11 -11
- package/Runtime/Entity/Models/StoreInventoryRequestModels.cs +236 -165
- package/Runtime/Entity/Models/StoreInventoryRequestModels.cs.meta +11 -11
- package/Runtime/Entity/Models/StoreInventoryResponseModels.cs +45 -30
- package/Runtime/Entity/Models/StoreInventoryResponseModels.cs.meta +11 -11
- package/Runtime/Entity/Models.meta +8 -8
- package/Runtime/Entity/OperationEvent.cs +111 -75
- package/Runtime/Entity/OperationEvent.cs.meta +11 -11
- package/Runtime/Entity/OperationHelper.cs +51 -35
- package/Runtime/Entity/OperationHelper.cs.meta +11 -11
- package/Runtime/Entity/OperationRequest.cs +142 -99
- package/Runtime/Entity/OperationRequest.cs.meta +11 -11
- package/Runtime/Entity/OperationResponse.cs +111 -63
- package/Runtime/Entity/OperationResponse.cs.meta +11 -11
- package/Runtime/Entity/Request/CustomOperationRequest.cs +112 -61
- package/Runtime/Entity/Request/CustomOperationRequest.cs.meta +11 -11
- package/Runtime/Entity/Request.meta +8 -8
- package/Runtime/Entity/Response/CustomOperationResponse.cs +84 -63
- package/Runtime/Entity/Response/CustomOperationResponse.cs.meta +11 -11
- package/Runtime/Entity/Response.meta +8 -8
- package/Runtime/Entity.meta +8 -8
- package/Runtime/GNNetwork.cs +501 -182
- package/Runtime/GNNetwork.cs.meta +11 -11
- package/Runtime/GNNetworkApi.cs +38 -19
- package/Runtime/GNNetworkApi.cs.meta +11 -11
- package/Runtime/GNNetworkAuthenticateApi.cs +531 -98
- package/Runtime/GNNetworkAuthenticateApi.cs.meta +11 -11
- package/Runtime/GNNetworkCharacterPlayerApi.cs +1587 -762
- package/Runtime/GNNetworkCharacterPlayerApi.cs.meta +11 -11
- package/Runtime/GNNetworkCloudScriptApi.cs +181 -0
- package/Runtime/GNNetworkCloudScriptApi.cs.meta +11 -0
- package/Runtime/GNNetworkContentApi.cs +238 -132
- package/Runtime/GNNetworkContentApi.cs.meta +11 -11
- package/Runtime/GNNetworkDashboardApi.cs +278 -117
- package/Runtime/GNNetworkDashboardApi.cs.meta +11 -11
- package/Runtime/GNNetworkGamePlayerApi.cs +1558 -747
- package/Runtime/GNNetworkGamePlayerApi.cs.meta +11 -11
- package/Runtime/GNNetworkGroupApi.cs +1228 -582
- package/Runtime/GNNetworkGroupApi.cs.meta +11 -11
- package/Runtime/GNNetworkInventoryApi.cs +1048 -507
- package/Runtime/GNNetworkInventoryApi.cs.meta +11 -11
- package/Runtime/GNNetworkMasterPlayerApi.cs +2586 -1067
- package/Runtime/GNNetworkMasterPlayerApi.cs.meta +11 -11
- package/Runtime/GNNetworkMultiplayerApi.cs +328 -147
- package/Runtime/GNNetworkMultiplayerApi.cs.meta +11 -11
- package/Runtime/GNNetworkStoreInventoryApi.cs +388 -162
- package/Runtime/GNNetworkStoreInventoryApi.cs.meta +11 -11
- package/Runtime/Helper/CodeHelper.cs +140 -98
- package/Runtime/Helper/CodeHelper.cs.meta +11 -11
- package/Runtime/Helper/ConverterService.cs +236 -52
- package/Runtime/Helper/ConverterService.cs.meta +11 -11
- package/Runtime/Helper/ParseGNHelper.cs +451 -451
- package/Runtime/Helper/ParseGNHelper.cs.meta +11 -11
- package/Runtime/Helper.meta +8 -8
- package/Runtime/Logger/GNDebug.cs +92 -49
- package/Runtime/Logger/GNDebug.cs.meta +11 -11
- package/Runtime/Logger.meta +8 -8
- package/Runtime/Networking/AuthenticateStatus.cs +57 -35
- package/Runtime/Networking/AuthenticateStatus.cs.meta +11 -11
- package/Runtime/Networking/Handler/IServerEventHandler.cs +25 -25
- package/Runtime/Networking/Handler/IServerEventHandler.cs.meta +11 -11
- package/Runtime/Networking/Handler/OnCharacterPlayerFriendUpdateEventHandler.cs +61 -32
- package/Runtime/Networking/Handler/OnCharacterPlayerFriendUpdateEventHandler.cs.meta +11 -11
- package/Runtime/Networking/Handler/OnCharacterPlayerGroupUpdateEventHandler.cs +54 -33
- package/Runtime/Networking/Handler/OnCharacterPlayerGroupUpdateEventHandler.cs.meta +11 -11
- package/Runtime/Networking/Handler/OnGamePlayerFriendUpdateEventHandler.cs +54 -32
- package/Runtime/Networking/Handler/OnGamePlayerFriendUpdateEventHandler.cs.meta +11 -11
- package/Runtime/Networking/Handler/OnGamePlayerGroupUpdateEventHandler.cs +54 -32
- package/Runtime/Networking/Handler/OnGamePlayerGroupUpdateEventHandler.cs.meta +11 -11
- package/Runtime/Networking/Handler/OnGroupMemberUpdateEventHandler.cs +48 -29
- package/Runtime/Networking/Handler/OnGroupMemberUpdateEventHandler.cs.meta +11 -11
- package/Runtime/Networking/Handler/OnGroupMessageUpdateEventHandler.cs +47 -29
- package/Runtime/Networking/Handler/OnGroupMessageUpdateEventHandler.cs.meta +11 -11
- package/Runtime/Networking/Handler.meta +8 -8
- package/Runtime/Networking/Http/HttpPeer.cs +68 -25
- package/Runtime/Networking/Http/HttpPeer.cs.meta +11 -11
- package/Runtime/Networking/Http/NetworkingHttpPeerBase.cs +65 -25
- package/Runtime/Networking/Http/NetworkingHttpPeerBase.cs.meta +11 -11
- package/Runtime/Networking/Http/NetworkingPeerHttpClientRequest.cs +513 -486
- package/Runtime/Networking/Http/NetworkingPeerHttpClientRequest.cs.meta +11 -11
- package/Runtime/Networking/Http/NetworkingPeerHttpRequest.cs +172 -142
- package/Runtime/Networking/Http/NetworkingPeerHttpRequest.cs.meta +11 -11
- package/Runtime/Networking/Http/NetworkingPeerUnityWebRequest.cs +225 -188
- package/Runtime/Networking/Http/NetworkingPeerUnityWebRequest.cs.meta +11 -11
- package/Runtime/Networking/Http.meta +8 -8
- package/Runtime/Networking/IPeer.cs +41 -19
- package/Runtime/Networking/IPeer.cs.meta +11 -11
- package/Runtime/Networking/NetworkingPeer.cs +198 -144
- package/Runtime/Networking/NetworkingPeer.cs.meta +11 -11
- package/Runtime/Networking/NetworkingPeerAPI.cs +20 -21
- package/Runtime/Networking/NetworkingPeerAPI.cs.meta +11 -11
- package/Runtime/Networking/OperationPending.cs +159 -95
- package/Runtime/Networking/OperationPending.cs.meta +11 -11
- package/Runtime/Networking/PeerBase.cs +305 -242
- package/Runtime/Networking/PeerBase.cs.meta +11 -11
- package/Runtime/Networking/Socket/NetworkingPeerSocketV2.cs +222 -185
- package/Runtime/Networking/Socket/NetworkingPeerSocketV2.cs.meta +11 -11
- package/Runtime/Networking/Socket/NetworkingPeerSocketV3.cs +235 -177
- package/Runtime/Networking/Socket/NetworkingPeerSocketV3.cs.meta +11 -11
- package/Runtime/Networking/Socket/NetworkingSocketPeerBase.cs +165 -23
- package/Runtime/Networking/Socket/NetworkingSocketPeerBase.cs.meta +11 -11
- package/Runtime/Networking/Socket/SocketPeer.cs +242 -197
- package/Runtime/Networking/Socket/SocketPeer.cs.meta +11 -11
- package/Runtime/Networking/Socket.meta +8 -8
- package/Runtime/Networking.meta +8 -8
- package/Runtime/Unity/ServiceCoroutine.cs +10 -0
- package/Runtime/Unity/ServiceCoroutine.cs.meta +11 -0
- package/Runtime/Unity/ServiceUpdate.cs +33 -20
- package/Runtime/Unity/ServiceUpdate.cs.meta +11 -11
- package/Runtime/Unity.meta +8 -8
- package/Runtime/XmobiTea.GN.runtime.asmdef +16 -16
- package/Runtime/XmobiTea.GN.runtime.asmdef.meta +7 -7
- package/package.json +1 -1
|
@@ -1,241 +1,404 @@
|
|
|
1
|
-
namespace XmobiTea.GN.Common
|
|
2
|
-
{
|
|
3
|
-
using System;
|
|
4
|
-
using System.Collections.Generic;
|
|
5
|
-
using System.Text;
|
|
6
|
-
|
|
7
|
-
/// <summary>
|
|
8
|
-
///
|
|
9
|
-
/// </summary>
|
|
10
|
-
public class GNHashtable : GNData
|
|
11
|
-
{
|
|
12
|
-
public class Builder
|
|
13
|
-
{
|
|
14
|
-
private IDictionary<string, object> dict;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
public
|
|
79
|
-
{
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
public
|
|
89
|
-
{
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
{
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
public
|
|
118
|
-
{
|
|
119
|
-
return
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
public
|
|
128
|
-
{
|
|
129
|
-
return
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
1
|
+
namespace XmobiTea.GN.Common
|
|
2
|
+
{
|
|
3
|
+
using System;
|
|
4
|
+
using System.Collections.Generic;
|
|
5
|
+
using System.Text;
|
|
6
|
+
|
|
7
|
+
/// <summary>
|
|
8
|
+
/// A hashtable implementation for GNData, supporting serialization and custom key-value storage.
|
|
9
|
+
/// </summary>
|
|
10
|
+
public class GNHashtable : GNData
|
|
11
|
+
{
|
|
12
|
+
public class Builder
|
|
13
|
+
{
|
|
14
|
+
private IDictionary<string, object> dict;
|
|
15
|
+
|
|
16
|
+
/// <summary>
|
|
17
|
+
/// Adds a key-value pair to the internal dictionary.
|
|
18
|
+
/// </summary>
|
|
19
|
+
/// <param name="key">The key for the entry, must be a string.</param>
|
|
20
|
+
/// <param name="value">The value for the entry.</param>
|
|
21
|
+
/// <returns>The current Builder instance.</returns>
|
|
22
|
+
public Builder add(string key, object value)
|
|
23
|
+
{
|
|
24
|
+
this.dict[key] = value;
|
|
25
|
+
|
|
26
|
+
return this;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/// <summary>
|
|
30
|
+
/// Adds all key-value pairs from an existing dictionary to the internal dictionary.
|
|
31
|
+
/// </summary>
|
|
32
|
+
/// <param name="dict">The dictionary containing key-value pairs to add.</param>
|
|
33
|
+
/// <returns>The current Builder instance.</returns>
|
|
34
|
+
public Builder addAll(System.Collections.IDictionary dict)
|
|
35
|
+
{
|
|
36
|
+
var keys = dict.Keys;
|
|
37
|
+
foreach (var key in keys)
|
|
38
|
+
{
|
|
39
|
+
if (key is string keyStr)
|
|
40
|
+
{
|
|
41
|
+
this.add(keyStr, dict[key]);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return this;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/// <summary>
|
|
48
|
+
/// Constructs a new GNHashtable instance using the current key-value pairs.
|
|
49
|
+
/// </summary>
|
|
50
|
+
/// <returns>A GNHashtable containing the added key-value pairs.</returns>
|
|
51
|
+
public GNHashtable build()
|
|
52
|
+
{
|
|
53
|
+
var answer = new GNHashtable();
|
|
54
|
+
|
|
55
|
+
var keys = this.dict.Keys;
|
|
56
|
+
foreach (var key in keys)
|
|
57
|
+
{
|
|
58
|
+
answer.add(key, this.dict[key]);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return answer;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/// <summary>
|
|
65
|
+
/// Initializes a new instance of the Builder class.
|
|
66
|
+
/// </summary>
|
|
67
|
+
public Builder()
|
|
68
|
+
{
|
|
69
|
+
this.dict = new Dictionary<string, object>();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
private IDictionary<string, object> dict;
|
|
74
|
+
|
|
75
|
+
/// <summary>
|
|
76
|
+
/// Initializes a new instance of the GNHashtable class.
|
|
77
|
+
/// </summary>
|
|
78
|
+
public GNHashtable()
|
|
79
|
+
{
|
|
80
|
+
this.dict = new Dictionary<string, object>();
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/// <summary>
|
|
84
|
+
/// Adds or updates a key-value pair in the hashtable.
|
|
85
|
+
/// </summary>
|
|
86
|
+
/// <param name="key">The key to add or update.</param>
|
|
87
|
+
/// <param name="value">The value associated with the key.</param>
|
|
88
|
+
public void add(string key, object value)
|
|
89
|
+
{
|
|
90
|
+
this.dict[key] = GNData.createUseDataFromOriginData(value);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/// <summary>
|
|
94
|
+
/// Gets or sets the value associated with the specified key.
|
|
95
|
+
/// </summary>
|
|
96
|
+
/// <param name="key">The key to get or set.</param>
|
|
97
|
+
/// <returns>The value associated with the key.</returns>
|
|
98
|
+
public object this[string key]
|
|
99
|
+
{
|
|
100
|
+
get => this.getObject(key);
|
|
101
|
+
set => this.add(key, value);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/// <summary>
|
|
105
|
+
/// Gets a collection of all values in the hashtable.
|
|
106
|
+
/// </summary>
|
|
107
|
+
/// <returns>A collection of all values in the hashtable.</returns>
|
|
108
|
+
public ICollection<object> values()
|
|
109
|
+
{
|
|
110
|
+
return this.dict.Values;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/// <summary>
|
|
114
|
+
/// Gets a collection of all keys in the hashtable.
|
|
115
|
+
/// </summary>
|
|
116
|
+
/// <returns>A collection of all keys in the hashtable.</returns>
|
|
117
|
+
public ICollection<string> keys()
|
|
118
|
+
{
|
|
119
|
+
return this.dict.Keys;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/// <summary>
|
|
123
|
+
/// Determines whether the hashtable contains the specified key.
|
|
124
|
+
/// </summary>
|
|
125
|
+
/// <param name="key">The key to locate.</param>
|
|
126
|
+
/// <returns>true if the hashtable contains the key; otherwise, false.</returns>
|
|
127
|
+
public bool containsKey(string key)
|
|
128
|
+
{
|
|
129
|
+
return this.dict.ContainsKey(key);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/// <summary>
|
|
133
|
+
/// Removes all key-value pairs from the hashtable.
|
|
134
|
+
/// </summary>
|
|
135
|
+
public void clear()
|
|
136
|
+
{
|
|
137
|
+
this.dict.Clear();
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/// <summary>
|
|
141
|
+
/// Removes the value associated with the specified key.
|
|
142
|
+
/// </summary>
|
|
143
|
+
/// <param name="key">The key of the value to remove.</param>
|
|
144
|
+
/// <returns>true if the value was successfully removed; otherwise, false.</returns>
|
|
145
|
+
public bool remove(string key)
|
|
146
|
+
{
|
|
147
|
+
return this.dict.Remove(key);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/// <summary>
|
|
151
|
+
/// Gets the number of key-value pairs in the hashtable.
|
|
152
|
+
/// </summary>
|
|
153
|
+
/// <returns>The number of key-value pairs in the hashtable.</returns>
|
|
154
|
+
public int count()
|
|
155
|
+
{
|
|
156
|
+
return this.dict.Count;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/// <summary>
|
|
160
|
+
/// Retrieves the value associated with the specified key, or a default value if the key does not exist.
|
|
161
|
+
/// </summary>
|
|
162
|
+
/// <typeparam name="T">The expected type of the value.</typeparam>
|
|
163
|
+
/// <param name="k">The key to locate.</param>
|
|
164
|
+
/// <param name="defaultValue">The default value to return if the key is not found.</param>
|
|
165
|
+
/// <returns>The value associated with the key, or the default value if the key is not found.</returns>
|
|
166
|
+
protected object get<T>(string k, T defaultValue = default(T))
|
|
167
|
+
{
|
|
168
|
+
if (this.dict.ContainsKey(k))
|
|
169
|
+
{
|
|
170
|
+
var value = this.dict[k];
|
|
171
|
+
|
|
172
|
+
if (value == null) return defaultValue;
|
|
173
|
+
|
|
174
|
+
if (value is T t)
|
|
175
|
+
{
|
|
176
|
+
return t;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return value;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
return defaultValue;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/// <summary>
|
|
186
|
+
/// Retrieves a byte value from the hashtable for the specified key.
|
|
187
|
+
/// </summary>
|
|
188
|
+
/// <param name="k">The key to lookup in the hashtable.</param>
|
|
189
|
+
/// <param name="defaultValue">The default value to return if the key does not exist or the value cannot be converted.</param>
|
|
190
|
+
/// <returns>The byte value associated with the key or the default value.</returns>
|
|
191
|
+
public byte getByte(string k, byte defaultValue = 0)
|
|
192
|
+
{
|
|
193
|
+
return Convert.ToByte(this.get(k, defaultValue));
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/// <summary>
|
|
197
|
+
/// Retrieves a signed byte (sbyte) value from the hashtable for the specified key.
|
|
198
|
+
/// </summary>
|
|
199
|
+
/// <param name="k">The key to lookup in the hashtable.</param>
|
|
200
|
+
/// <param name="defaultValue">The default value to return if the key does not exist or the value cannot be converted.</param>
|
|
201
|
+
/// <returns>The sbyte value associated with the key or the default value.</returns>
|
|
202
|
+
public sbyte getSByte(string k, sbyte defaultValue = 0)
|
|
203
|
+
{
|
|
204
|
+
return Convert.ToSByte(this.get(k, defaultValue));
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/// <summary>
|
|
208
|
+
/// Retrieves a short value from the hashtable for the specified key.
|
|
209
|
+
/// </summary>
|
|
210
|
+
/// <param name="k">The key to lookup in the hashtable.</param>
|
|
211
|
+
/// <param name="defaultValue">The default value to return if the key does not exist or the value cannot be converted.</param>
|
|
212
|
+
/// <returns>The short value associated with the key or the default value.</returns>
|
|
213
|
+
public short getShort(string k, short defaultValue = 0)
|
|
214
|
+
{
|
|
215
|
+
return Convert.ToInt16(this.get(k, defaultValue));
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/// <summary>
|
|
219
|
+
/// Retrieves an integer value from the hashtable for the specified key.
|
|
220
|
+
/// </summary>
|
|
221
|
+
/// <param name="k">The key to lookup in the hashtable.</param>
|
|
222
|
+
/// <param name="defaultValue">The default value to return if the key does not exist or the value cannot be converted.</param>
|
|
223
|
+
/// <returns>The integer value associated with the key or the default value.</returns>
|
|
224
|
+
public int getInt(string k, int defaultValue = 0)
|
|
225
|
+
{
|
|
226
|
+
return Convert.ToInt32(this.get(k, defaultValue));
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/// <summary>
|
|
230
|
+
/// Retrieves a float value from the hashtable for the specified key.
|
|
231
|
+
/// </summary>
|
|
232
|
+
/// <param name="k">The key to lookup in the hashtable.</param>
|
|
233
|
+
/// <param name="defaultValue">The default value to return if the key does not exist or the value cannot be converted.</param>
|
|
234
|
+
/// <returns>The float value associated with the key or the default value.</returns>
|
|
235
|
+
public float getFloat(string k, float defaultValue = 0)
|
|
236
|
+
{
|
|
237
|
+
return Convert.ToSingle(this.get(k, defaultValue));
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/// <summary>
|
|
241
|
+
/// Retrieves a long value from the hashtable for the specified key.
|
|
242
|
+
/// </summary>
|
|
243
|
+
/// <param name="k">The key to lookup in the hashtable.</param>
|
|
244
|
+
/// <param name="defaultValue">The default value to return if the key does not exist or the value cannot be converted.</param>
|
|
245
|
+
/// <returns>The long value associated with the key or the default value.</returns>
|
|
246
|
+
public long getLong(string k, long defaultValue = 0)
|
|
247
|
+
{
|
|
248
|
+
return Convert.ToInt64(this.get(k, defaultValue));
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/// <summary>
|
|
252
|
+
/// Retrieves a double value from the hashtable for the specified key.
|
|
253
|
+
/// </summary>
|
|
254
|
+
/// <param name="k">The key to lookup in the hashtable.</param>
|
|
255
|
+
/// <param name="defaultValue">The default value to return if the key does not exist or the value cannot be converted.</param>
|
|
256
|
+
/// <returns>The double value associated with the key or the default value.</returns>
|
|
257
|
+
public double getDouble(string k, double defaultValue = 0)
|
|
258
|
+
{
|
|
259
|
+
return Convert.ToDouble(this.get(k, defaultValue));
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/// <summary>
|
|
263
|
+
/// Retrieves a boolean value from the hashtable for the specified key.
|
|
264
|
+
/// </summary>
|
|
265
|
+
/// <param name="k">The key to lookup in the hashtable.</param>
|
|
266
|
+
/// <param name="defaultValue">The default value to return if the key does not exist or the value cannot be converted.</param>
|
|
267
|
+
/// <returns>The boolean value associated with the key or the default value.</returns>
|
|
268
|
+
public bool getBool(string k, bool defaultValue = false)
|
|
269
|
+
{
|
|
270
|
+
return Convert.ToBoolean(this.get(k, defaultValue));
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/// <summary>
|
|
274
|
+
/// Retrieves a string value from the hashtable for the specified key.
|
|
275
|
+
/// </summary>
|
|
276
|
+
/// <param name="k">The key to lookup in the hashtable.</param>
|
|
277
|
+
/// <param name="defaultValue">The default value to return if the key does not exist or the value cannot be converted.</param>
|
|
278
|
+
/// <returns>The string value associated with the key or the default value.</returns>
|
|
279
|
+
public string getString(string k, string defaultValue = null)
|
|
280
|
+
{
|
|
281
|
+
return Convert.ToString(this.get(k, defaultValue));
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/// <summary>
|
|
285
|
+
/// Retrieves a raw object from the hashtable for the specified key.
|
|
286
|
+
/// </summary>
|
|
287
|
+
/// <param name="k">The key to lookup in the hashtable.</param>
|
|
288
|
+
/// <param name="defaultValue">The default value to return if the key does not exist or the value cannot be converted.</param>
|
|
289
|
+
/// <returns>The object associated with the key or the default value.</returns>
|
|
290
|
+
public object getObject(string k, object defaultValue = null)
|
|
291
|
+
{
|
|
292
|
+
return this.get(k, defaultValue);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/// <summary>
|
|
296
|
+
/// Retrieves an array of type <typeparamref name="T"/> from the hashtable for the specified key.
|
|
297
|
+
/// </summary>
|
|
298
|
+
/// <param name="k">The key to lookup in the hashtable.</param>
|
|
299
|
+
/// <param name="defaultValue">The default value to return if the key does not exist or cannot be converted.</param>
|
|
300
|
+
/// <returns>An array of type <typeparamref name="T"/> or the default value.</returns>
|
|
301
|
+
public T[] getArray<T>(string k, T[] defaultValue = null)
|
|
302
|
+
{
|
|
303
|
+
var value0 = this.getGNArray(k);
|
|
304
|
+
if (value0 != null)
|
|
305
|
+
{
|
|
306
|
+
return value0.toArray<T>();
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
return defaultValue;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/// <summary>
|
|
313
|
+
/// Retrieves a list of type <typeparamref name="T"/> from the hashtable for the specified key.
|
|
314
|
+
/// </summary>
|
|
315
|
+
/// <param name="k">The key to lookup in the hashtable.</param>
|
|
316
|
+
/// <param name="defaultValue">The default value to return if the key does not exist or cannot be converted.</param>
|
|
317
|
+
/// <returns>A list of type <typeparamref name="T"/> or the default value.</returns>
|
|
318
|
+
public IList<T> getList<T>(string k, IList<T> defaultValue = null)
|
|
319
|
+
{
|
|
320
|
+
var value0 = this.getGNArray(k);
|
|
321
|
+
if (value0 != null)
|
|
322
|
+
{
|
|
323
|
+
return value0.toList<T>();
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
return defaultValue;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/// <summary>
|
|
330
|
+
/// Retrieves a <see cref="GNArray"/> from the hashtable for the specified key.
|
|
331
|
+
/// </summary>
|
|
332
|
+
/// <param name="k">The key to lookup in the hashtable.</param>
|
|
333
|
+
/// <param name="defaultValue">The default value to return if the key does not exist or cannot be converted.</param>
|
|
334
|
+
/// <returns>A <see cref="GNArray"/> or the default value.</returns>
|
|
335
|
+
public GNArray getGNArray(string k, GNArray defaultValue = null)
|
|
336
|
+
{
|
|
337
|
+
return (GNArray)this.get(k, defaultValue);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/// <summary>
|
|
341
|
+
/// Retrieves a <see cref="GNHashtable"/> from the hashtable for the specified key.
|
|
342
|
+
/// </summary>
|
|
343
|
+
/// <param name="k">The key to lookup in the hashtable.</param>
|
|
344
|
+
/// <param name="defaultValue">The default value to return if the key does not exist or cannot be converted.</param>
|
|
345
|
+
/// <returns>A <see cref="GNHashtable"/> or the default value.</returns>
|
|
346
|
+
public GNHashtable getGNHashtable(string k, GNHashtable defaultValue = null)
|
|
347
|
+
{
|
|
348
|
+
return (GNHashtable)this.get(k, defaultValue);
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
/// <summary>
|
|
352
|
+
/// Converts the hashtable to a raw data dictionary suitable for external use.
|
|
353
|
+
/// </summary>
|
|
354
|
+
/// <returns>A dictionary containing the hashtable's key-value pairs as raw data.</returns>
|
|
355
|
+
public override object toData()
|
|
356
|
+
{
|
|
357
|
+
var answer = new Dictionary<string, object>();
|
|
358
|
+
|
|
359
|
+
foreach (var c in this.dict)
|
|
360
|
+
{
|
|
361
|
+
answer.Add(c.Key, GNData.createDataFromUseData(c.Value));
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
return answer;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/// <summary>
|
|
368
|
+
/// Converts the hashtable to its string representation in JSON-like format.
|
|
369
|
+
/// </summary>
|
|
370
|
+
/// <returns>A string representing the hashtable.</returns>
|
|
371
|
+
public override string toString()
|
|
372
|
+
{
|
|
373
|
+
var stringBuilder = new StringBuilder();
|
|
374
|
+
stringBuilder.Append("{");
|
|
375
|
+
|
|
376
|
+
var i = 0;
|
|
377
|
+
foreach (var c in this.dict)
|
|
378
|
+
{
|
|
379
|
+
if (i != 0) stringBuilder.Append(",");
|
|
380
|
+
|
|
381
|
+
i++;
|
|
382
|
+
var value = c.Value;
|
|
383
|
+
if (value == null) stringBuilder.Append($"\"{c.Key}\":null");
|
|
384
|
+
else if (value is GNData gnData) stringBuilder.Append($"\"{c.Key}\":{gnData.ToString()}");
|
|
385
|
+
else if (value is string valueStr) stringBuilder.Append($"\"{c.Key}\":\"{valueStr}\"");
|
|
386
|
+
else if (value is bool boolValue) stringBuilder.Append($"\"{c.Key}\":{boolValue.ToString().ToLower()}");
|
|
387
|
+
else stringBuilder.Append($"\"{c.Key}\":{value}");
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
stringBuilder.Append("}");
|
|
391
|
+
return stringBuilder.ToString();
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
/// <summary>
|
|
395
|
+
/// Overrides the default <see cref="object.ToString"/> method to return the hashtable's string representation.
|
|
396
|
+
/// </summary>
|
|
397
|
+
/// <returns>A string representing the hashtable.</returns>
|
|
398
|
+
public override string ToString()
|
|
399
|
+
{
|
|
400
|
+
return this.toString();
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
}
|