145 lines
4.5 KiB
C#
145 lines
4.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace UnityEngine.Networking.Match
|
|
{
|
|
// Token: 0x020002A5 RID: 677
|
|
internal abstract class ResponseBase
|
|
{
|
|
// Token: 0x06002DC6 RID: 11718
|
|
public abstract void Parse(object obj);
|
|
|
|
// Token: 0x06002DC7 RID: 11719 RVA: 0x00041680 File Offset: 0x0003F880
|
|
public string ParseJSONString(string name, object obj, IDictionary<string, object> dictJsonObj)
|
|
{
|
|
if (dictJsonObj.TryGetValue(name, out obj))
|
|
{
|
|
return obj as string;
|
|
}
|
|
throw new FormatException(name + " not found in JSON dictionary");
|
|
}
|
|
|
|
// Token: 0x06002DC8 RID: 11720 RVA: 0x000416BC File Offset: 0x0003F8BC
|
|
public short ParseJSONInt16(string name, object obj, IDictionary<string, object> dictJsonObj)
|
|
{
|
|
if (dictJsonObj.TryGetValue(name, out obj))
|
|
{
|
|
return Convert.ToInt16(obj);
|
|
}
|
|
throw new FormatException(name + " not found in JSON dictionary");
|
|
}
|
|
|
|
// Token: 0x06002DC9 RID: 11721 RVA: 0x000416F8 File Offset: 0x0003F8F8
|
|
public int ParseJSONInt32(string name, object obj, IDictionary<string, object> dictJsonObj)
|
|
{
|
|
if (dictJsonObj.TryGetValue(name, out obj))
|
|
{
|
|
return Convert.ToInt32(obj);
|
|
}
|
|
throw new FormatException(name + " not found in JSON dictionary");
|
|
}
|
|
|
|
// Token: 0x06002DCA RID: 11722 RVA: 0x00041734 File Offset: 0x0003F934
|
|
public long ParseJSONInt64(string name, object obj, IDictionary<string, object> dictJsonObj)
|
|
{
|
|
if (dictJsonObj.TryGetValue(name, out obj))
|
|
{
|
|
return Convert.ToInt64(obj);
|
|
}
|
|
throw new FormatException(name + " not found in JSON dictionary");
|
|
}
|
|
|
|
// Token: 0x06002DCB RID: 11723 RVA: 0x00041770 File Offset: 0x0003F970
|
|
public ushort ParseJSONUInt16(string name, object obj, IDictionary<string, object> dictJsonObj)
|
|
{
|
|
if (dictJsonObj.TryGetValue(name, out obj))
|
|
{
|
|
return Convert.ToUInt16(obj);
|
|
}
|
|
throw new FormatException(name + " not found in JSON dictionary");
|
|
}
|
|
|
|
// Token: 0x06002DCC RID: 11724 RVA: 0x000417AC File Offset: 0x0003F9AC
|
|
public uint ParseJSONUInt32(string name, object obj, IDictionary<string, object> dictJsonObj)
|
|
{
|
|
if (dictJsonObj.TryGetValue(name, out obj))
|
|
{
|
|
return Convert.ToUInt32(obj);
|
|
}
|
|
throw new FormatException(name + " not found in JSON dictionary");
|
|
}
|
|
|
|
// Token: 0x06002DCD RID: 11725 RVA: 0x000417E8 File Offset: 0x0003F9E8
|
|
public ulong ParseJSONUInt64(string name, object obj, IDictionary<string, object> dictJsonObj)
|
|
{
|
|
if (dictJsonObj.TryGetValue(name, out obj))
|
|
{
|
|
return Convert.ToUInt64(obj);
|
|
}
|
|
throw new FormatException(name + " not found in JSON dictionary");
|
|
}
|
|
|
|
// Token: 0x06002DCE RID: 11726 RVA: 0x00041824 File Offset: 0x0003FA24
|
|
public bool ParseJSONBool(string name, object obj, IDictionary<string, object> dictJsonObj)
|
|
{
|
|
if (dictJsonObj.TryGetValue(name, out obj))
|
|
{
|
|
return Convert.ToBoolean(obj);
|
|
}
|
|
throw new FormatException(name + " not found in JSON dictionary");
|
|
}
|
|
|
|
// Token: 0x06002DCF RID: 11727 RVA: 0x00041860 File Offset: 0x0003FA60
|
|
public DateTime ParseJSONDateTime(string name, object obj, IDictionary<string, object> dictJsonObj)
|
|
{
|
|
throw new FormatException(name + " DateTime not yet supported");
|
|
}
|
|
|
|
// Token: 0x06002DD0 RID: 11728 RVA: 0x00041874 File Offset: 0x0003FA74
|
|
public List<string> ParseJSONListOfStrings(string name, object obj, IDictionary<string, object> dictJsonObj)
|
|
{
|
|
if (dictJsonObj.TryGetValue(name, out obj))
|
|
{
|
|
List<object> list = obj as List<object>;
|
|
if (list != null)
|
|
{
|
|
List<string> list2 = new List<string>();
|
|
foreach (object obj2 in list)
|
|
{
|
|
IDictionary<string, object> dictionary = (IDictionary<string, object>)obj2;
|
|
foreach (KeyValuePair<string, object> keyValuePair in dictionary)
|
|
{
|
|
string text = (string)keyValuePair.Value;
|
|
list2.Add(text);
|
|
}
|
|
}
|
|
return list2;
|
|
}
|
|
}
|
|
throw new FormatException(name + " not found in JSON dictionary");
|
|
}
|
|
|
|
// Token: 0x06002DD1 RID: 11729 RVA: 0x00041968 File Offset: 0x0003FB68
|
|
public List<T> ParseJSONList<T>(string name, object obj, IDictionary<string, object> dictJsonObj) where T : ResponseBase, new()
|
|
{
|
|
if (dictJsonObj.TryGetValue(name, out obj))
|
|
{
|
|
List<object> list = obj as List<object>;
|
|
if (list != null)
|
|
{
|
|
List<T> list2 = new List<T>();
|
|
foreach (object obj2 in list)
|
|
{
|
|
IDictionary<string, object> dictionary = (IDictionary<string, object>)obj2;
|
|
T t = new T();
|
|
t.Parse(dictionary);
|
|
list2.Add(t);
|
|
}
|
|
return list2;
|
|
}
|
|
}
|
|
throw new FormatException(name + " not found in JSON dictionary");
|
|
}
|
|
}
|
|
}
|