initial commit

This commit is contained in:
Arneth
2022-01-20 17:32:17 -05:00
parent f570a902d9
commit 07448bc23d
446 changed files with 53095 additions and 60 deletions
@@ -0,0 +1,109 @@
using System;
using UnityEngine;
namespace Prime31
{
// Token: 0x0200000D RID: 13
public abstract class AbstractManager : MonoBehaviour
{
// Token: 0x17000007 RID: 7
// (get) Token: 0x0600004C RID: 76 RVA: 0x00004354 File Offset: 0x00002554
public static MonoBehaviour coroutineSurrogate
{
get
{
if (AbstractManager._prime31GameObjectMonobehaviourRef == null)
{
GameObject prime31ManagerGameObject = AbstractManager.getPrime31ManagerGameObject();
AbstractManager._prime31GameObjectMonobehaviourRef = prime31ManagerGameObject.AddComponent<MonoBehaviour>();
}
return AbstractManager._prime31GameObjectMonobehaviourRef;
}
}
// Token: 0x0600004E RID: 78 RVA: 0x0000439C File Offset: 0x0000259C
public static ThreadingCallbackHelper getThreadingCallbackHelper()
{
return AbstractManager._threadingCallbackHelper;
}
// Token: 0x0600004F RID: 79 RVA: 0x000043B8 File Offset: 0x000025B8
public static void createThreadingCallbackHelper()
{
if (!(AbstractManager._threadingCallbackHelper != null))
{
AbstractManager._threadingCallbackHelper = (UnityEngine.Object.FindObjectOfType(typeof(ThreadingCallbackHelper)) as ThreadingCallbackHelper);
if (!(AbstractManager._threadingCallbackHelper != null))
{
GameObject prime31ManagerGameObject = AbstractManager.getPrime31ManagerGameObject();
AbstractManager._threadingCallbackHelper = prime31ManagerGameObject.AddComponent<ThreadingCallbackHelper>();
}
}
}
// Token: 0x06000050 RID: 80 RVA: 0x0000441C File Offset: 0x0000261C
public static GameObject getPrime31ManagerGameObject()
{
GameObject prime31GameObject;
if (AbstractManager._prime31GameObject != null)
{
prime31GameObject = AbstractManager._prime31GameObject;
}
else
{
AbstractManager._prime31GameObject = GameObject.Find("prime[31]");
if (AbstractManager._prime31GameObject == null)
{
AbstractManager._prime31GameObject = new GameObject("prime[31]");
UnityEngine.Object.DontDestroyOnLoad(AbstractManager._prime31GameObject);
}
prime31GameObject = AbstractManager._prime31GameObject;
}
return prime31GameObject;
}
// Token: 0x06000051 RID: 81 RVA: 0x0000448C File Offset: 0x0000268C
public static void initialize(Type type)
{
try
{
MonoBehaviour x = UnityEngine.Object.FindObjectOfType(type) as MonoBehaviour;
if (!(x != null))
{
GameObject prime31ManagerGameObject = AbstractManager.getPrime31ManagerGameObject();
GameObject gameObject = new GameObject(type.ToString());
gameObject.AddComponent(type);
gameObject.transform.parent = prime31ManagerGameObject.transform;
UnityEngine.Object.DontDestroyOnLoad(gameObject);
}
}
catch (UnityException)
{
Debug.LogWarning(string.Concat(new object[]
{
"It looks like you have the ",
type,
" on a GameObject in your scene. Our new prefab-less manager system does not require the ",
type,
" to be on a GameObject.\nIt will be added to your scene at runtime automatically for you. Please remove the script from your scene."
}));
}
}
// Token: 0x06000052 RID: 82 RVA: 0x00004538 File Offset: 0x00002738
private void Awake()
{
base.gameObject.name = base.GetType().ToString();
UnityEngine.Object.DontDestroyOnLoad(this);
}
// Token: 0x0400001F RID: 31
private static MonoBehaviour _prime31GameObjectMonobehaviourRef;
// Token: 0x04000020 RID: 32
private static ThreadingCallbackHelper _threadingCallbackHelper;
// Token: 0x04000021 RID: 33
private static GameObject _prime31GameObject;
}
}
@@ -0,0 +1,86 @@
using System;
using UnityEngine;
namespace Prime31
{
// Token: 0x02000007 RID: 7
public static class ActionExtensions
{
// Token: 0x0600001C RID: 28 RVA: 0x00002DC0 File Offset: 0x00000FC0
private static void invoke(Delegate listener, object[] args)
{
if (!listener.Method.IsStatic && (listener.Target == null || listener.Target.Equals(null)))
{
Debug.LogError("an event listener is still subscribed to an event with the method " + listener.Method.Name + " even though it is null. Be sure to balance your event subscriptions.");
}
else
{
listener.Method.Invoke(listener.Target, args);
}
}
// Token: 0x0600001D RID: 29 RVA: 0x00002E34 File Offset: 0x00001034
public static void fire(this Action handler)
{
if (handler != null)
{
object[] args = new object[0];
foreach (Delegate listener in handler.GetInvocationList())
{
ActionExtensions.invoke(listener, args);
}
}
}
// Token: 0x0600001E RID: 30 RVA: 0x00002E7C File Offset: 0x0000107C
public static void fire<T>(this Action<T> handler, T param)
{
if (handler != null)
{
object[] args = new object[]
{
param
};
foreach (Delegate listener in handler.GetInvocationList())
{
ActionExtensions.invoke(listener, args);
}
}
}
// Token: 0x0600001F RID: 31 RVA: 0x00002ECC File Offset: 0x000010CC
public static void fire<T, U>(this Action<T, U> handler, T param1, U param2)
{
if (handler != null)
{
object[] args = new object[]
{
param1,
param2
};
foreach (Delegate listener in handler.GetInvocationList())
{
ActionExtensions.invoke(listener, args);
}
}
}
// Token: 0x06000020 RID: 32 RVA: 0x00002F28 File Offset: 0x00001128
public static void fire<T, U, V>(this Action<T, U, V> handler, T param1, U param2, V param3)
{
if (handler != null)
{
object[] args = new object[]
{
param1,
param2,
param3
};
foreach (Delegate listener in handler.GetInvocationList())
{
ActionExtensions.invoke(listener, args);
}
}
}
}
}
+107
View File
@@ -0,0 +1,107 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Text;
namespace Prime31
{
// Token: 0x0200000F RID: 15
public class DTOBase
{
// Token: 0x06000058 RID: 88 RVA: 0x000046A4 File Offset: 0x000028A4
public static List<T> listFromJson<T>(string json) where T : DTOBase
{
List<object> list = json.listFromJson();
List<T> list2 = new List<T>();
foreach (object obj in list)
{
T item = Activator.CreateInstance<T>();
item.setDataFromDictionary(obj as Dictionary<string, object>);
list2.Add(item);
}
return list2;
}
// Token: 0x06000059 RID: 89 RVA: 0x00004734 File Offset: 0x00002934
public void setDataFromJson(string json)
{
this.setDataFromDictionary(json.dictionaryFromJson());
}
// Token: 0x0600005A RID: 90 RVA: 0x00004744 File Offset: 0x00002944
public void setDataFromDictionary(Dictionary<string, object> dict)
{
Dictionary<string, Action<object>> membersWithSetters = this.getMembersWithSetters();
foreach (KeyValuePair<string, object> keyValuePair in dict)
{
if (membersWithSetters.ContainsKey(keyValuePair.Key))
{
try
{
membersWithSetters[keyValuePair.Key](keyValuePair.Value);
}
catch (Exception obj)
{
Utils.logObject(obj);
}
}
}
}
// Token: 0x0600005B RID: 91 RVA: 0x000047F0 File Offset: 0x000029F0
private bool shouldIncludeTypeWithSetters(Type type)
{
return !type.IsGenericType && type.Namespace.StartsWith("System");
}
// Token: 0x0600005C RID: 92 RVA: 0x00004834 File Offset: 0x00002A34
protected Dictionary<string, Action<object>> getMembersWithSetters()
{
Dictionary<string, Action<object>> dictionary = new Dictionary<string, Action<object>>();
FieldInfo[] fields = base.GetType().GetFields();
for (int i = 0; i < fields.Length; i++)
{
FieldInfo fieldInfo = fields[i];
if (this.shouldIncludeTypeWithSetters(fieldInfo.FieldType))
{
FieldInfo theInfo = fieldInfo;
dictionary[fieldInfo.Name] = delegate(object val)
{
theInfo.SetValue(this, val);
};
}
}
foreach (PropertyInfo propertyInfo in base.GetType().GetProperties())
{
if (this.shouldIncludeTypeWithSetters(propertyInfo.PropertyType))
{
if (propertyInfo.CanWrite && propertyInfo.GetSetMethod() != null)
{
PropertyInfo theInfo = propertyInfo;
dictionary[propertyInfo.Name] = delegate(object val)
{
theInfo.SetValue(this, val, null);
};
}
}
}
return dictionary;
}
// Token: 0x0600005D RID: 93 RVA: 0x00004954 File Offset: 0x00002B54
public override string ToString()
{
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.AppendFormat("[{0}]:", base.GetType());
foreach (FieldInfo fieldInfo in base.GetType().GetFields())
{
stringBuilder.AppendFormat(", {0}: {1}", fieldInfo.Name, fieldInfo.GetValue(this));
}
foreach (PropertyInfo propertyInfo in base.GetType().GetProperties())
{
stringBuilder.AppendFormat(", {0}: {1}", propertyInfo.Name, propertyInfo.GetValue(this, null));
}
return stringBuilder.ToString();
}
}
}
@@ -0,0 +1,15 @@
using System;
namespace Prime31
{
// Token: 0x02000008 RID: 8
public static class DateTimeExtensions
{
// Token: 0x06000021 RID: 33 RVA: 0x00002F8C File Offset: 0x0000118C
public static long toEpochTime(this DateTime self)
{
DateTime d = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
return Convert.ToInt64((self - d).TotalSeconds);
}
}
}
@@ -0,0 +1,191 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using UnityEngine;
namespace Prime31
{
// Token: 0x02000005 RID: 5
public static class DeserializationExtensions
{
// Token: 0x06000015 RID: 21 RVA: 0x00002878 File Offset: 0x00000A78
public static List<T> toList<T>(this IList self)
{
List<T> list = new List<T>();
IEnumerator enumerator = self.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
object obj = enumerator.Current;
Dictionary<string, object> self2 = (Dictionary<string, object>)obj;
list.Add(self2.toClass<T>());
}
}
finally
{
IDisposable disposable;
if ((disposable = (enumerator as IDisposable)) != null)
{
disposable.Dispose();
}
}
return list;
}
// Token: 0x06000016 RID: 22 RVA: 0x000028F0 File Offset: 0x00000AF0
public static T toClass<T>(this IDictionary self)
{
object obj = Activator.CreateInstance(typeof(T));
foreach (FieldInfo fieldInfo in typeof(T).GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic))
{
object[] customAttributes = fieldInfo.GetCustomAttributes(typeof(P31DeserializeableFieldAttribute), true);
int j = 0;
while (j < customAttributes.Length)
{
object obj2 = customAttributes[j];
P31DeserializeableFieldAttribute p31DeserializeableFieldAttribute = obj2 as P31DeserializeableFieldAttribute;
if (self.Contains(p31DeserializeableFieldAttribute.key))
{
object obj3 = self[p31DeserializeableFieldAttribute.key];
if (obj3 is IDictionary)
{
MethodInfo methodInfo = typeof(DeserializationExtensions).GetMethod("toClass").MakeGenericMethod(new Type[]
{
p31DeserializeableFieldAttribute.type
});
object value = methodInfo.Invoke(null, new object[]
{
obj3
});
fieldInfo.SetValue(obj, value);
self.Remove(p31DeserializeableFieldAttribute.key);
}
else if (obj3 is IList)
{
if (!p31DeserializeableFieldAttribute.isCollection)
{
Debug.LogError("found an IList but the field is not a collection: " + p31DeserializeableFieldAttribute.key);
}
else
{
MethodInfo methodInfo2 = typeof(DeserializationExtensions).GetMethod("toList").MakeGenericMethod(new Type[]
{
p31DeserializeableFieldAttribute.type
});
object value2 = methodInfo2.Invoke(null, new object[]
{
obj3
});
fieldInfo.SetValue(obj, value2);
self.Remove(p31DeserializeableFieldAttribute.key);
}
}
else
{
fieldInfo.SetValue(obj, Convert.ChangeType(obj3, fieldInfo.FieldType));
self.Remove(p31DeserializeableFieldAttribute.key);
}
}
IL_19E:
j++;
continue;
goto IL_19E;
}
}
return (T)((object)obj);
}
// Token: 0x06000017 RID: 23 RVA: 0x00002ACC File Offset: 0x00000CCC
public static Dictionary<string, object> toDictionary(this object self)
{
Dictionary<string, object> dictionary = new Dictionary<string, object>();
foreach (FieldInfo fieldInfo in self.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic))
{
foreach (object obj in fieldInfo.GetCustomAttributes(typeof(P31DeserializeableFieldAttribute), true))
{
P31DeserializeableFieldAttribute p31DeserializeableFieldAttribute = obj as P31DeserializeableFieldAttribute;
if (p31DeserializeableFieldAttribute.isCollection)
{
IEnumerable enumerable = fieldInfo.GetValue(self) as IEnumerable;
ArrayList arrayList = new ArrayList();
IEnumerator enumerator = enumerable.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
object self2 = enumerator.Current;
arrayList.Add(self2.toDictionary());
}
}
finally
{
IDisposable disposable;
if ((disposable = (enumerator as IDisposable)) != null)
{
disposable.Dispose();
}
}
dictionary[p31DeserializeableFieldAttribute.key] = arrayList;
}
else if (p31DeserializeableFieldAttribute.type != null)
{
dictionary[p31DeserializeableFieldAttribute.key] = fieldInfo.GetValue(self).toDictionary();
}
else
{
dictionary[p31DeserializeableFieldAttribute.key] = fieldInfo.GetValue(self);
}
}
}
return dictionary;
}
// Token: 0x06000018 RID: 24 RVA: 0x00002C2C File Offset: 0x00000E2C
[Obsolete("Use the toDictionary method to get a proper generic Dictionary returned. Hashtables are obsolute.")]
public static Hashtable toHashtable(this object self)
{
Hashtable hashtable = new Hashtable();
foreach (FieldInfo fieldInfo in self.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic))
{
foreach (object obj in fieldInfo.GetCustomAttributes(typeof(P31DeserializeableFieldAttribute), true))
{
P31DeserializeableFieldAttribute p31DeserializeableFieldAttribute = obj as P31DeserializeableFieldAttribute;
if (p31DeserializeableFieldAttribute.isCollection)
{
IEnumerable enumerable = fieldInfo.GetValue(self) as IEnumerable;
ArrayList arrayList = new ArrayList();
IEnumerator enumerator = enumerable.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
object self2 = enumerator.Current;
arrayList.Add(self2.toHashtable());
}
}
finally
{
IDisposable disposable;
if ((disposable = (enumerator as IDisposable)) != null)
{
disposable.Dispose();
}
}
hashtable[p31DeserializeableFieldAttribute.key] = arrayList;
}
else if (p31DeserializeableFieldAttribute.type != null)
{
hashtable[p31DeserializeableFieldAttribute.key] = fieldInfo.GetValue(self).toHashtable();
}
else
{
hashtable[p31DeserializeableFieldAttribute.key] = fieldInfo.GetValue(self);
}
}
}
return hashtable;
}
}
}
+17
View File
@@ -0,0 +1,17 @@
using System;
namespace Prime31
{
// Token: 0x02000002 RID: 2
public enum HTTPVerb
{
// Token: 0x04000002 RID: 2
GET,
// Token: 0x04000003 RID: 3
POST,
// Token: 0x04000004 RID: 4
PUT,
// Token: 0x04000005 RID: 5
DELETE
}
}
@@ -0,0 +1,14 @@
using System;
namespace Prime31
{
// Token: 0x0200001B RID: 27
public interface IJsonSerializerStrategy
{
// Token: 0x060000A8 RID: 168
bool serializeNonPrimitiveObject(object input, out object output);
// Token: 0x060000A9 RID: 169
object deserializeObject(object value, Type type);
}
}
+892
View File
@@ -0,0 +1,892 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Reflection;
using System.Text;
namespace Prime31
{
// Token: 0x02000010 RID: 16
public class Json
{
// Token: 0x0600005F RID: 95 RVA: 0x00004A54 File Offset: 0x00002C54
public static object decode(string json)
{
object result;
if (Json.useSimpleJson)
{
result = SimpleJson.decode(json);
}
else
{
object obj = Json.Deserializer.deserialize(json);
if (obj == null)
{
Utils.logObject("Something went wrong deserializing the json. We got a null return. Here is the json we tried to deserialize: " + json);
}
result = obj;
}
return result;
}
// Token: 0x06000060 RID: 96 RVA: 0x00004AA0 File Offset: 0x00002CA0
public static T decode<T>(string json, string rootElement = null) where T : new()
{
T result;
if (Json.useSimpleJson)
{
result = SimpleJson.decode<T>(json, rootElement);
}
else
{
result = (T)((object)Json.ObjectDecoder.decode<T>(json, rootElement));
}
return result;
}
// Token: 0x06000061 RID: 97 RVA: 0x00004AD8 File Offset: 0x00002CD8
public static T decodeObject<T>(object jsonObject, string rootElement = null) where T : new()
{
return SimpleJson.decodeObject<T>(jsonObject, rootElement);
}
// Token: 0x06000062 RID: 98 RVA: 0x00004AF4 File Offset: 0x00002CF4
public static string encode(object obj)
{
string text = (!Json.useSimpleJson) ? Json.Serializer.serialize(obj) : SimpleJson.encode(obj);
if (text == null)
{
Utils.logObject("Something went wrong serializing the object. We got a null return. Here is the object we tried to deserialize: ");
Utils.logObject(obj);
}
return text;
}
// Token: 0x06000063 RID: 99 RVA: 0x00004B40 File Offset: 0x00002D40
public static object jsonDecode(string json)
{
return Json.decode(json);
}
// Token: 0x06000064 RID: 100 RVA: 0x00004B5C File Offset: 0x00002D5C
public static string jsonEncode(object obj)
{
string text = Json.Serializer.serialize(obj);
if (text == null)
{
Utils.logObject("Something went wrong serializing the object. We got a null return. Here is the object we tried to deserialize: ");
Utils.logObject(obj);
}
return text;
}
// Token: 0x04000024 RID: 36
public static bool useSimpleJson;
// Token: 0x02000011 RID: 17
internal class ObjectDecoder
{
// Token: 0x06000066 RID: 102 RVA: 0x00004B9C File Offset: 0x00002D9C
public static object decode<T>(string json, string rootElement = null) where T : new()
{
object obj = Json.decode(json);
object result;
if (obj == null)
{
result = null;
}
else
{
result = new Json.ObjectDecoder().decode<T>(obj, rootElement);
}
return result;
}
// Token: 0x06000067 RID: 103 RVA: 0x00004BD4 File Offset: 0x00002DD4
private object decode<T>(object decodedJsonObject, string rootElement = null) where T : new()
{
if (rootElement != null)
{
IDictionary dictionary = decodedJsonObject as IDictionary;
if (dictionary == null)
{
Utils.logObject(string.Concat(new object[]
{
"A rootElement was requested (",
rootElement,
") but the json did not decode to a Dictionary. It decoded to: ",
decodedJsonObject
}));
return null;
}
if (!dictionary.Contains(rootElement))
{
Utils.logObject("A rootElement was requested (" + rootElement + ") but does not exist in the decoded Dictionary");
return null;
}
decodedJsonObject = dictionary[rootElement];
}
Type type = typeof(T);
IList list = null;
object result;
if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(List<>))
{
list = (Activator.CreateInstance<T>() as IList);
type = list.GetType().GetGenericArguments()[0];
if (!(decodedJsonObject is IList) || !decodedJsonObject.GetType().IsGenericType)
{
Utils.logObject("A List was required but the json did not decode to a List. It decoded to: " + decodedJsonObject);
result = null;
}
else
{
IEnumerator enumerator = ((IList)decodedJsonObject).GetEnumerator();
try
{
while (enumerator.MoveNext())
{
object obj = enumerator.Current;
Dictionary<string, object> dictionary2 = (Dictionary<string, object>)obj;
if (dictionary2 == null)
{
Utils.logObject("Aborted populating List because the json did not decode to a List of Dictionaries");
return list;
}
list.Add(this.createAndPopulateObjectFromDictionary(type, dictionary2));
}
}
finally
{
IDisposable disposable;
if ((disposable = (enumerator as IDisposable)) != null)
{
disposable.Dispose();
}
}
result = list;
}
}
else
{
result = this.createAndPopulateObjectFromDictionary(type, decodedJsonObject as Dictionary<string, object>);
}
return result;
}
// Token: 0x06000068 RID: 104 RVA: 0x00004D78 File Offset: 0x00002F78
private Dictionary<string, Action<object, object>> getMemberInfoForObject(object obj)
{
if (this._memberInfo == null)
{
this._memberInfo = Json.ObjectDecoder.getMembersWithSetters(obj);
}
return this._memberInfo;
}
// Token: 0x06000069 RID: 105 RVA: 0x00004DAC File Offset: 0x00002FAC
private static Dictionary<string, Action<object, object>> getMembersWithSetters(object obj)
{
Dictionary<string, Action<object, object>> dictionary = new Dictionary<string, Action<object, object>>();
FieldInfo[] fields = obj.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
for (int i = 0; i < fields.Length; i++)
{
FieldInfo fieldInfo = fields[i];
if (fieldInfo.FieldType.Namespace.StartsWith("System"))
{
FieldInfo theInfo = fieldInfo;
Type theFieldType = fieldInfo.FieldType;
dictionary[fieldInfo.Name] = delegate(object ownerObject, object val)
{
theInfo.SetValue(ownerObject, Convert.ChangeType(val, theFieldType));
};
}
}
foreach (PropertyInfo propertyInfo in obj.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic))
{
if (propertyInfo.PropertyType.Namespace.StartsWith("System"))
{
if (propertyInfo.CanWrite && propertyInfo.GetSetMethod(true) != null)
{
PropertyInfo theInfo = propertyInfo;
Type thePropertyType = propertyInfo.PropertyType;
dictionary[propertyInfo.Name] = delegate(object ownerObject, object val)
{
theInfo.SetValue(ownerObject, Convert.ChangeType(val, thePropertyType), null);
};
}
}
}
return dictionary;
}
// Token: 0x0600006A RID: 106 RVA: 0x00004EEC File Offset: 0x000030EC
public object createAndPopulateObjectFromDictionary(Type objectType, Dictionary<string, object> dict)
{
object obj = Activator.CreateInstance(objectType);
Dictionary<string, Action<object, object>> memberInfoForObject = this.getMemberInfoForObject(obj);
Dictionary<string, object>.KeyCollection keys = dict.Keys;
foreach (string key in keys)
{
if (memberInfoForObject.ContainsKey(key))
{
try
{
memberInfoForObject[key](obj, dict[key]);
}
catch (Exception obj2)
{
Utils.logObject(obj2);
}
}
}
return obj;
}
// Token: 0x04000025 RID: 37
private Dictionary<string, Action<object, object>> _memberInfo;
}
// Token: 0x02000012 RID: 18
internal class Deserializer
{
// Token: 0x0600006B RID: 107 RVA: 0x00004FEF File Offset: 0x000031EF
private Deserializer(string json)
{
this.charArray = json.ToCharArray();
}
// Token: 0x0600006C RID: 108 RVA: 0x00005004 File Offset: 0x00003204
public static object deserialize(string json)
{
object result;
if (json != null)
{
Json.Deserializer deserializer = new Json.Deserializer(json);
result = deserializer.deserialize();
}
else
{
result = null;
}
return result;
}
// Token: 0x0600006D RID: 109 RVA: 0x00005038 File Offset: 0x00003238
private object deserialize()
{
int num = 0;
return this.parseValue(this.charArray, ref num);
}
// Token: 0x0600006E RID: 110 RVA: 0x00005060 File Offset: 0x00003260
protected object parseValue(char[] json, ref int index)
{
switch (this.lookAhead(json, index))
{
case Json.Deserializer.JsonToken.CurlyOpen:
return this.parseObject(json, ref index);
case Json.Deserializer.JsonToken.SquaredOpen:
return this.parseArray(json, ref index);
case Json.Deserializer.JsonToken.String:
return this.parseString(json, ref index);
case Json.Deserializer.JsonToken.Number:
return this.parseNumber(json, ref index);
case Json.Deserializer.JsonToken.True:
this.nextToken(json, ref index);
return bool.Parse("TRUE");
case Json.Deserializer.JsonToken.False:
this.nextToken(json, ref index);
return bool.Parse("FALSE");
case Json.Deserializer.JsonToken.Null:
this.nextToken(json, ref index);
return null;
}
return null;
}
// Token: 0x0600006F RID: 111 RVA: 0x00005144 File Offset: 0x00003344
private IDictionary parseObject(char[] json, ref int index)
{
IDictionary dictionary = new Dictionary<string, object>();
this.nextToken(json, ref index);
bool flag = false;
while (!flag)
{
Json.Deserializer.JsonToken jsonToken = this.lookAhead(json, index);
if (jsonToken != Json.Deserializer.JsonToken.None)
{
if (jsonToken == Json.Deserializer.JsonToken.Comma)
{
this.nextToken(json, ref index);
}
else
{
if (jsonToken == Json.Deserializer.JsonToken.CurlyClose)
{
this.nextToken(json, ref index);
return dictionary;
}
string text = this.parseString(json, ref index);
if (text == null)
{
return null;
}
jsonToken = this.nextToken(json, ref index);
if (jsonToken != Json.Deserializer.JsonToken.Colon)
{
return null;
}
object value = this.parseValue(json, ref index);
dictionary[text] = value;
}
continue;
}
return null;
}
return dictionary;
}
// Token: 0x06000070 RID: 112 RVA: 0x00005204 File Offset: 0x00003404
private IList parseArray(char[] json, ref int index)
{
List<object> list = new List<object>();
this.nextToken(json, ref index);
bool flag = false;
while (!flag)
{
Json.Deserializer.JsonToken jsonToken = this.lookAhead(json, index);
if (jsonToken == Json.Deserializer.JsonToken.None)
{
return null;
}
if (jsonToken == Json.Deserializer.JsonToken.Comma)
{
this.nextToken(json, ref index);
}
else
{
if (jsonToken == Json.Deserializer.JsonToken.SquaredClose)
{
this.nextToken(json, ref index);
break;
}
object item = this.parseValue(json, ref index);
list.Add(item);
}
}
return list;
}
// Token: 0x06000071 RID: 113 RVA: 0x00005294 File Offset: 0x00003494
private string parseString(char[] json, ref int index)
{
string text = string.Empty;
this.eatWhitespace(json, ref index);
char c = json[index++];
bool flag = false;
while (!flag)
{
if (index == json.Length)
{
break;
}
c = json[index++];
if (c == '"')
{
flag = true;
break;
}
if (c == '\\')
{
if (index == json.Length)
{
break;
}
c = json[index++];
if (c == '"')
{
text += '"';
}
else if (c == '\\')
{
text += '\\';
}
else if (c == '/')
{
text += '/';
}
else if (c == 'b')
{
text += '\b';
}
else if (c == 'f')
{
text += '\f';
}
else if (c == 'n')
{
text += '\n';
}
else if (c == 'r')
{
text += '\r';
}
else if (c == 't')
{
text += '\t';
}
else if (c == 'u')
{
int num = json.Length - index;
if (num < 4)
{
break;
}
char[] array = new char[4];
Array.Copy(json, index, array, 0, 4);
uint utf = uint.Parse(new string(array), NumberStyles.HexNumber);
try
{
text += char.ConvertFromUtf32((int)utf);
}
catch (Exception)
{
foreach (char c2 in array)
{
text += c2;
}
}
index += 4;
}
}
else
{
text += c;
}
}
string result;
if (!flag)
{
result = null;
}
else
{
result = text;
}
return result;
}
// Token: 0x06000072 RID: 114 RVA: 0x000054E4 File Offset: 0x000036E4
private object parseNumber(char[] json, ref int index)
{
this.eatWhitespace(json, ref index);
int lastIndexOfNumber = this.getLastIndexOfNumber(json, index);
int num = lastIndexOfNumber - index + 1;
char[] array = new char[num];
Array.Copy(json, index, array, 0, num);
index = lastIndexOfNumber + 1;
string text = new string(array);
if (!text.Contains("."))
{
long num2;
if (long.TryParse(text, NumberStyles.Integer, CultureInfo.InvariantCulture, out num2))
{
return num2;
}
}
return double.Parse(new string(array), CultureInfo.InvariantCulture);
}
// Token: 0x06000073 RID: 115 RVA: 0x0000557C File Offset: 0x0000377C
private int getLastIndexOfNumber(char[] json, int index)
{
int i;
for (i = index; i < json.Length; i++)
{
if ("0123456789+-.eE".IndexOf(json[i]) == -1)
{
break;
}
}
return i - 1;
}
// Token: 0x06000074 RID: 116 RVA: 0x000055C2 File Offset: 0x000037C2
private void eatWhitespace(char[] json, ref int index)
{
while (index < json.Length)
{
if (" \t\n\r".IndexOf(json[index]) == -1)
{
break;
}
index++;
}
}
// Token: 0x06000075 RID: 117 RVA: 0x000055F8 File Offset: 0x000037F8
private Json.Deserializer.JsonToken lookAhead(char[] json, int index)
{
int num = index;
return this.nextToken(json, ref num);
}
// Token: 0x06000076 RID: 118 RVA: 0x00005618 File Offset: 0x00003818
private Json.Deserializer.JsonToken nextToken(char[] json, ref int index)
{
this.eatWhitespace(json, ref index);
Json.Deserializer.JsonToken result;
if (index == json.Length)
{
result = Json.Deserializer.JsonToken.None;
}
else
{
char c = json[index];
index++;
switch (c)
{
case ',':
result = Json.Deserializer.JsonToken.Comma;
break;
case '-':
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
result = Json.Deserializer.JsonToken.Number;
break;
default:
switch (c)
{
case '[':
result = Json.Deserializer.JsonToken.SquaredOpen;
break;
default:
switch (c)
{
case '{':
result = Json.Deserializer.JsonToken.CurlyOpen;
break;
default:
if (c != '"')
{
index--;
int num = json.Length - index;
if (num >= 5)
{
if (json[index] == 'f' && json[index + 1] == 'a' && json[index + 2] == 'l' && json[index + 3] == 's' && json[index + 4] == 'e')
{
index += 5;
result = Json.Deserializer.JsonToken.False;
break;
}
}
if (num >= 4)
{
if (json[index] == 't' && json[index + 1] == 'r' && json[index + 2] == 'u' && json[index + 3] == 'e')
{
index += 4;
result = Json.Deserializer.JsonToken.True;
break;
}
}
if (num >= 4)
{
if (json[index] == 'n' && json[index + 1] == 'u' && json[index + 2] == 'l' && json[index + 3] == 'l')
{
index += 4;
result = Json.Deserializer.JsonToken.Null;
break;
}
}
result = Json.Deserializer.JsonToken.None;
}
else
{
result = Json.Deserializer.JsonToken.String;
}
break;
case '}':
result = Json.Deserializer.JsonToken.CurlyClose;
break;
}
break;
case ']':
result = Json.Deserializer.JsonToken.SquaredClose;
break;
}
break;
case ':':
result = Json.Deserializer.JsonToken.Colon;
break;
}
}
return result;
}
// Token: 0x04000026 RID: 38
private char[] charArray;
// Token: 0x02000013 RID: 19
private enum JsonToken
{
// Token: 0x04000028 RID: 40
None,
// Token: 0x04000029 RID: 41
CurlyOpen,
// Token: 0x0400002A RID: 42
CurlyClose,
// Token: 0x0400002B RID: 43
SquaredOpen,
// Token: 0x0400002C RID: 44
SquaredClose,
// Token: 0x0400002D RID: 45
Colon,
// Token: 0x0400002E RID: 46
Comma,
// Token: 0x0400002F RID: 47
String,
// Token: 0x04000030 RID: 48
Number,
// Token: 0x04000031 RID: 49
True,
// Token: 0x04000032 RID: 50
False,
// Token: 0x04000033 RID: 51
Null
}
}
// Token: 0x02000014 RID: 20
internal class Serializer
{
// Token: 0x06000077 RID: 119 RVA: 0x000057FE File Offset: 0x000039FE
private Serializer()
{
this._builder = new StringBuilder();
}
// Token: 0x06000078 RID: 120 RVA: 0x00005814 File Offset: 0x00003A14
public static string serialize(object obj)
{
Json.Serializer serializer = new Json.Serializer();
serializer.serializeObject(obj);
return serializer._builder.ToString();
}
// Token: 0x06000079 RID: 121 RVA: 0x00005844 File Offset: 0x00003A44
private void serializeObject(object value)
{
if (value == null)
{
this._builder.Append("null");
}
else if (value is string)
{
this.serializeString((string)value);
}
else if (value is IList)
{
this.serializeIList((IList)value);
}
else if (value is Dictionary<string, object>)
{
this.serializeDictionary((Dictionary<string, object>)value);
}
else if (value is IDictionary)
{
this.serializeIDictionary((IDictionary)value);
}
else if (value is bool)
{
this._builder.Append(value.ToString().ToLower());
}
else if (value.GetType().IsPrimitive)
{
this._builder.Append(value);
}
else if (value is DateTime)
{
DateTime value2 = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
double totalMilliseconds = ((DateTime)value).Subtract(value2).TotalMilliseconds;
this.serializeString(Convert.ToString(totalMilliseconds, CultureInfo.InvariantCulture));
}
else
{
try
{
this.serializeClass(value);
}
catch (Exception ex)
{
Utils.logObject(string.Format("failed to serialize {0} with error: {1}", value, ex.Message));
}
}
}
// Token: 0x0600007A RID: 122 RVA: 0x000059C4 File Offset: 0x00003BC4
private void serializeIList(IList anArray)
{
this._builder.Append("[");
bool flag = true;
for (int i = 0; i < anArray.Count; i++)
{
object value = anArray[i];
if (!flag)
{
this._builder.Append(", ");
}
this.serializeObject(value);
flag = false;
}
this._builder.Append("]");
}
// Token: 0x0600007B RID: 123 RVA: 0x00005A38 File Offset: 0x00003C38
private void serializeIDictionary(IDictionary dict)
{
this._builder.Append("{");
bool flag = true;
IEnumerator enumerator = dict.Keys.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
object obj = enumerator.Current;
if (!flag)
{
this._builder.Append(", ");
}
this.serializeString(obj.ToString());
this._builder.Append(":");
this.serializeObject(dict[obj]);
flag = false;
}
}
finally
{
IDisposable disposable;
if ((disposable = (enumerator as IDisposable)) != null)
{
disposable.Dispose();
}
}
this._builder.Append("}");
}
// Token: 0x0600007C RID: 124 RVA: 0x00005AFC File Offset: 0x00003CFC
private void serializeDictionary(Dictionary<string, object> dict)
{
this._builder.Append("{");
bool flag = true;
Dictionary<string, object>.KeyCollection keys = dict.Keys;
foreach (string text in keys)
{
if (!flag)
{
this._builder.Append(", ");
}
this.serializeString(text.ToString());
this._builder.Append(":");
this.serializeObject(dict[text]);
flag = false;
}
this._builder.Append("}");
}
// Token: 0x0600007D RID: 125 RVA: 0x00005BC0 File Offset: 0x00003DC0
private void serializeString(string str)
{
this._builder.Append("\"");
foreach (char c in str.ToCharArray())
{
if (c == '"')
{
this._builder.Append("\\\"");
}
else if (c == '\\')
{
this._builder.Append("\\\\");
}
else if (c == '\b')
{
this._builder.Append("\\b");
}
else if (c == '\f')
{
this._builder.Append("\\f");
}
else if (c == '\n')
{
this._builder.Append("\\n");
}
else if (c == '\r')
{
this._builder.Append("\\r");
}
else if (c == '\t')
{
this._builder.Append("\\t");
}
else
{
int num = Convert.ToInt32(c, CultureInfo.InvariantCulture);
if (num >= 32 && num <= 126)
{
this._builder.Append(c);
}
else
{
this._builder.Append("\\u" + Convert.ToString(num, 16).PadLeft(4, '0'));
}
}
}
this._builder.Append("\"");
}
// Token: 0x0600007E RID: 126 RVA: 0x00005D4C File Offset: 0x00003F4C
private void serializeClass(object value)
{
this._builder.Append("{");
bool flag = true;
foreach (FieldInfo fieldInfo in value.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic))
{
if (!fieldInfo.IsPrivate || !fieldInfo.Name.Contains("k__BackingField"))
{
if (!flag)
{
this._builder.Append(", ");
}
this.serializeString(fieldInfo.Name);
this._builder.Append(":");
this.serializeObject(fieldInfo.GetValue(value));
flag = false;
}
}
foreach (PropertyInfo propertyInfo in value.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic))
{
if (!flag)
{
this._builder.Append(", ");
}
this.serializeString(propertyInfo.Name);
this._builder.Append(":");
this.serializeObject(propertyInfo.GetValue(value, null));
flag = false;
}
this._builder.Append("}");
}
// Token: 0x04000034 RID: 52
private StringBuilder _builder;
}
}
}
+25
View File
@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
namespace Prime31
{
// Token: 0x02000018 RID: 24
public class JsonArray : List<object>
{
// Token: 0x06000088 RID: 136 RVA: 0x0000630E File Offset: 0x0000450E
public JsonArray()
{
}
// Token: 0x06000089 RID: 137 RVA: 0x00006317 File Offset: 0x00004517
public JsonArray(int capacity) : base(capacity)
{
}
// Token: 0x0600008A RID: 138 RVA: 0x00006324 File Offset: 0x00004524
public override string ToString()
{
return JsonFormatter.prettyPrint(SimpleJson.encode(this)) ?? string.Empty;
}
}
}
@@ -0,0 +1,34 @@
using System;
using System.Collections;
using System.Collections.Generic;
namespace Prime31
{
// Token: 0x02000015 RID: 21
public static class JsonExtensions
{
// Token: 0x0600007F RID: 127 RVA: 0x00005E88 File Offset: 0x00004088
public static string toJson(this IList obj)
{
return Json.encode(obj);
}
// Token: 0x06000080 RID: 128 RVA: 0x00005EA4 File Offset: 0x000040A4
public static string toJson(this IDictionary obj)
{
return Json.encode(obj);
}
// Token: 0x06000081 RID: 129 RVA: 0x00005EC0 File Offset: 0x000040C0
public static List<object> listFromJson(this string json)
{
return Json.decode(json) as List<object>;
}
// Token: 0x06000082 RID: 130 RVA: 0x00005EE0 File Offset: 0x000040E0
public static Dictionary<string, object> dictionaryFromJson(this string json)
{
return Json.decode(json) as Dictionary<string, object>;
}
}
}
+211
View File
@@ -0,0 +1,211 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Prime31
{
// Token: 0x02000016 RID: 22
public class JsonFormatter
{
// Token: 0x06000084 RID: 132 RVA: 0x00005F30 File Offset: 0x00004130
public static string prettyPrint(string input)
{
string result;
try
{
result = new JsonFormatter().print(input);
}
catch (Exception)
{
result = null;
}
return result;
}
// Token: 0x06000085 RID: 133 RVA: 0x00005F6C File Offset: 0x0000416C
private static void buildIndents(int indents, StringBuilder output)
{
for (indents = indents; indents > 0; indents--)
{
output.Append("\t");
}
}
// Token: 0x06000086 RID: 134 RVA: 0x00005F90 File Offset: 0x00004190
private bool inString()
{
return this.inDoubleString || this.inSingleString;
}
// Token: 0x06000087 RID: 135 RVA: 0x00005FBC File Offset: 0x000041BC
public string print(string input)
{
StringBuilder stringBuilder = new StringBuilder(input.Length * 2);
foreach (char c in input)
{
switch (c)
{
case ' ':
if (this.inString())
{
stringBuilder.Append(c);
}
break;
default:
switch (c)
{
case ':':
if (!this.inString())
{
this.inVariableAssignment = true;
stringBuilder.Append(c);
stringBuilder.Append(" ");
}
else
{
stringBuilder.Append(c);
}
break;
default:
switch (c)
{
case '[':
stringBuilder.Append(c);
if (!this.inString())
{
this.context.Push(JsonFormatter.JsonContextType.Array);
}
break;
default:
switch (c)
{
case '{':
if (!this.inString())
{
if (this.inVariableAssignment || (this.context.Count > 0 && this.context.Peek() != JsonFormatter.JsonContextType.Array))
{
stringBuilder.Append(Environment.NewLine);
JsonFormatter.buildIndents(this.context.Count, stringBuilder);
}
stringBuilder.Append(c);
this.context.Push(JsonFormatter.JsonContextType.Object);
stringBuilder.Append(Environment.NewLine);
JsonFormatter.buildIndents(this.context.Count, stringBuilder);
}
else
{
stringBuilder.Append(c);
}
break;
default:
if (c != '\'')
{
if (c != ',')
{
stringBuilder.Append(c);
}
else
{
stringBuilder.Append(c);
if (!this.inString())
{
stringBuilder.Append(" ");
}
if (!this.inString() && this.context.Peek() != JsonFormatter.JsonContextType.Array)
{
JsonFormatter.buildIndents(this.context.Count, stringBuilder);
stringBuilder.Append(Environment.NewLine);
JsonFormatter.buildIndents(this.context.Count, stringBuilder);
this.inVariableAssignment = false;
}
}
}
else
{
if (!this.inDoubleString && this.prevChar != '\\')
{
this.inSingleString = !this.inSingleString;
}
stringBuilder.Append(c);
}
break;
case '}':
if (!this.inString())
{
stringBuilder.Append(Environment.NewLine);
this.context.Pop();
JsonFormatter.buildIndents(this.context.Count, stringBuilder);
stringBuilder.Append(c);
}
else
{
stringBuilder.Append(c);
}
break;
}
break;
case ']':
if (!this.inString())
{
stringBuilder.Append(c);
this.context.Pop();
}
else
{
stringBuilder.Append(c);
}
break;
}
break;
case '=':
stringBuilder.Append(c);
break;
}
break;
case '"':
if (!this.inSingleString && this.prevChar != '\\')
{
this.inDoubleString = !this.inDoubleString;
}
stringBuilder.Append(c);
break;
}
this.prevChar = c;
}
return stringBuilder.ToString();
}
// Token: 0x04000035 RID: 53
private const int defaultIndent = 0;
// Token: 0x04000036 RID: 54
private const string indent = "\t";
// Token: 0x04000037 RID: 55
private const string space = " ";
// Token: 0x04000038 RID: 56
private bool inDoubleString = false;
// Token: 0x04000039 RID: 57
private bool inSingleString = false;
// Token: 0x0400003A RID: 58
private bool inVariableAssignment = false;
// Token: 0x0400003B RID: 59
private char prevChar = '\0';
// Token: 0x0400003C RID: 60
private Stack<JsonFormatter.JsonContextType> context = new Stack<JsonFormatter.JsonContextType>();
// Token: 0x02000017 RID: 23
private enum JsonContextType
{
// Token: 0x0400003E RID: 62
Object,
// Token: 0x0400003F RID: 63
Array
}
}
}
+15
View File
@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
namespace Prime31
{
// Token: 0x02000019 RID: 25
public class JsonObject : Dictionary<string, object>
{
// Token: 0x0600008C RID: 140 RVA: 0x00006358 File Offset: 0x00004558
public override string ToString()
{
return JsonFormatter.prettyPrint(SimpleJson.encode(this)) ?? string.Empty;
}
}
}
@@ -0,0 +1,211 @@
using System;
using System.Collections.Generic;
using System.Text;
using UnityEngine;
namespace Prime31
{
// Token: 0x0200000C RID: 12
public class MonoBehaviourGUI : MonoBehaviour
{
// Token: 0x0600003E RID: 62 RVA: 0x00003DF8 File Offset: 0x00001FF8
private bool isRetinaOrLargeScreen()
{
return this._isWindowsPhone || Screen.width >= 960 || Screen.height >= 960;
}
// Token: 0x0600003F RID: 63 RVA: 0x00003E3C File Offset: 0x0000203C
private void paintWindow(int id)
{
GUI.skin.label.alignment = TextAnchor.UpperLeft;
this._logScrollPosition = GUILayout.BeginScrollView(this._logScrollPosition, new GUILayoutOption[0]);
if (GUILayout.Button("Clear Console", new GUILayoutOption[0]))
{
this._logBuilder.Remove(0, this._logBuilder.Length);
}
GUILayout.Label(this._logBuilder.ToString(), new GUILayoutOption[0]);
GUILayout.EndScrollView();
}
// Token: 0x06000040 RID: 64 RVA: 0x00003EB9 File Offset: 0x000020B9
private void handleLog(string logString, string stackTrace, LogType type)
{
this._logBuilder.AppendFormat("{0}\n", logString);
}
// Token: 0x06000041 RID: 65 RVA: 0x00003ECE File Offset: 0x000020CE
private void OnDestroy()
{
Application.RegisterLogCallback(null);
}
// Token: 0x06000042 RID: 66 RVA: 0x00003ED8 File Offset: 0x000020D8
private void Update()
{
if (!this._logRegistered)
{
Application.RegisterLogCallback(new Application.LogCallback(this.handleLog));
this._logRegistered = true;
this._isWindowsPhone = Application.platform.ToString().ToLower().Contains("wp8");
}
bool flag = false;
if (Input.GetMouseButtonDown(0))
{
float num = Time.time - this._previousClickTime;
if (num < this._doubleClickDelay)
{
flag = true;
}
else
{
this._previousClickTime = Time.time;
}
}
if (Input.touchCount == 2 || flag)
{
this._isShowingLogConsole = !this._isShowingLogConsole;
}
}
// Token: 0x06000043 RID: 67 RVA: 0x00003F8C File Offset: 0x0000218C
protected void beginColumn()
{
this._width = (float)(Screen.width / 2 - 15);
this._buttonHeight = (float)((!this.isRetinaOrLargeScreen()) ? 30 : 70);
GUI.skin.button.margin = new RectOffset(0, 0, 10, 0);
GUI.skin.button.stretchWidth = true;
GUI.skin.button.fixedHeight = this._buttonHeight;
GUI.skin.button.wordWrap = false;
if (this._isShowingLogConsole)
{
GUILayout.BeginArea(new Rect(0f, 0f, 0f, 0f));
}
else
{
GUILayout.BeginArea(new Rect(10f, 10f, this._width, (float)Screen.height));
}
GUILayout.BeginVertical(new GUILayoutOption[0]);
}
// Token: 0x06000044 RID: 68 RVA: 0x0000406D File Offset: 0x0000226D
protected void endColumn()
{
this.endColumn(false);
}
// Token: 0x06000045 RID: 69 RVA: 0x00004078 File Offset: 0x00002278
protected void endColumn(bool hasSecondColumn)
{
GUILayout.EndVertical();
GUILayout.EndArea();
if (this._isShowingLogConsole)
{
GUILayout.Window(1, new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), new GUI.WindowFunction(this.paintWindow), "prime[31] Log Console - double tap to dismiss", new GUILayoutOption[0]);
}
if (hasSecondColumn)
{
this.beginRightColumn();
}
}
// Token: 0x06000046 RID: 70 RVA: 0x000040E0 File Offset: 0x000022E0
private void beginRightColumn()
{
if (this._isShowingLogConsole)
{
GUILayout.BeginArea(new Rect(0f, 0f, 0f, 0f));
}
else
{
GUILayout.BeginArea(new Rect((float)Screen.width - this._width - 10f, 10f, this._width, (float)Screen.height));
}
GUILayout.BeginVertical(new GUILayoutOption[0]);
}
// Token: 0x06000047 RID: 71 RVA: 0x00004158 File Offset: 0x00002358
protected bool bottomRightButton(string text, float width = 150f)
{
return GUI.Button(new Rect((float)Screen.width - width - 10f, (float)Screen.height - this._buttonHeight - 10f, width, this._buttonHeight), text);
}
// Token: 0x06000048 RID: 72 RVA: 0x000041A0 File Offset: 0x000023A0
protected bool bottomLeftButton(string text, float width = 150f)
{
return GUI.Button(new Rect(10f, (float)Screen.height - this._buttonHeight - 10f, width, this._buttonHeight), text);
}
// Token: 0x06000049 RID: 73 RVA: 0x000041E0 File Offset: 0x000023E0
protected bool bottomCenterButton(string text, float width = 150f)
{
float left = (float)(Screen.width / 2) - width / 2f;
return GUI.Button(new Rect(left, (float)Screen.height - this._buttonHeight - 10f, width, this._buttonHeight), text);
}
// Token: 0x0600004A RID: 74 RVA: 0x0000422C File Offset: 0x0000242C
protected bool toggleButton(string defaultText, string selectedText)
{
if (!this._toggleButtons.ContainsKey(defaultText))
{
this._toggleButtons[defaultText] = true;
}
string text = (!this._toggleButtons[defaultText]) ? selectedText : defaultText;
if (!this._toggleButtons[defaultText])
{
GUI.skin.button.fontStyle = FontStyle.BoldAndItalic;
GUI.contentColor = Color.yellow;
}
else
{
GUI.skin.button.fontStyle = FontStyle.Bold;
GUI.contentColor = Color.red;
}
if (GUILayout.Button(text, new GUILayoutOption[0]))
{
this._toggleButtons[defaultText] = (text != defaultText);
}
GUI.skin.button.fontStyle = FontStyle.Normal;
GUI.contentColor = Color.white;
return this._toggleButtons[defaultText];
}
// Token: 0x0600004B RID: 75 RVA: 0x00004314 File Offset: 0x00002514
protected bool toggleButtonState(string defaultText)
{
if (!this._toggleButtons.ContainsKey(defaultText))
{
this._toggleButtons[defaultText] = true;
}
return this._toggleButtons[defaultText];
}
// Token: 0x04000015 RID: 21
protected float _width;
// Token: 0x04000016 RID: 22
protected float _buttonHeight;
// Token: 0x04000017 RID: 23
protected Dictionary<string, bool> _toggleButtons = new Dictionary<string, bool>();
// Token: 0x04000018 RID: 24
protected StringBuilder _logBuilder = new StringBuilder();
// Token: 0x04000019 RID: 25
private bool _logRegistered;
// Token: 0x0400001A RID: 26
private Vector2 _logScrollPosition;
// Token: 0x0400001B RID: 27
private bool _isShowingLogConsole;
// Token: 0x0400001C RID: 28
private float _doubleClickDelay = 0.15f;
// Token: 0x0400001D RID: 29
private float _previousClickTime;
// Token: 0x0400001E RID: 30
private bool _isWindowsPhone;
}
}
+366
View File
@@ -0,0 +1,366 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Security.Cryptography;
using System.Text;
namespace Prime31
{
// Token: 0x0200000A RID: 10
public class OAuthManager
{
// Token: 0x06000023 RID: 35 RVA: 0x00003078 File Offset: 0x00001278
public OAuthManager()
{
this._random = new Random();
this._params = new SortedDictionary<string, string>();
this._params["consumer_key"] = "";
this._params["consumer_secret"] = "";
this._params["timestamp"] = this.generateTimeStamp();
this._params["nonce"] = this.generateNonce();
this._params["signature_method"] = "HMAC-SHA1";
this._params["signature"] = "";
this._params["token"] = "";
this._params["token_secret"] = "";
this._params["version"] = "1.0";
}
// Token: 0x06000024 RID: 36 RVA: 0x00003164 File Offset: 0x00001364
public OAuthManager(string consumerKey, string consumerSecret, string token, string tokenSecret) : this()
{
this._params["consumer_key"] = consumerKey;
this._params["consumer_secret"] = consumerSecret;
this._params["token"] = token;
this._params["token_secret"] = tokenSecret;
}
// Token: 0x17000004 RID: 4
public string this[string ix]
{
get
{
if (this._params.ContainsKey(ix))
{
return this._params[ix];
}
throw new ArgumentException(ix);
}
set
{
if (!this._params.ContainsKey(ix))
{
throw new ArgumentException(ix);
}
this._params[ix] = value;
}
}
// Token: 0x06000027 RID: 39 RVA: 0x00003224 File Offset: 0x00001424
private string generateTimeStamp()
{
return Convert.ToInt64((DateTime.UtcNow - OAuthManager._epoch).TotalSeconds).ToString();
}
// Token: 0x06000028 RID: 40 RVA: 0x00003263 File Offset: 0x00001463
private void prepareNewRequest()
{
this._params["nonce"] = this.generateNonce();
this._params["timestamp"] = this.generateTimeStamp();
}
// Token: 0x06000029 RID: 41 RVA: 0x00003294 File Offset: 0x00001494
private string generateNonce()
{
StringBuilder stringBuilder = new StringBuilder();
for (int i = 0; i < 8; i++)
{
int num = this._random.Next(3);
if (num != 0)
{
stringBuilder.Append((char)(this._random.Next(10) + 48), 1);
}
else
{
stringBuilder.Append((char)(this._random.Next(26) + 97), 1);
}
}
return stringBuilder.ToString();
}
// Token: 0x0600002A RID: 42 RVA: 0x00003320 File Offset: 0x00001520
private SortedDictionary<string, string> extractQueryParameters(string queryString)
{
if (queryString.StartsWith("?"))
{
queryString = queryString.Remove(0, 1);
}
SortedDictionary<string, string> sortedDictionary = new SortedDictionary<string, string>();
SortedDictionary<string, string> result;
if (string.IsNullOrEmpty(queryString))
{
result = sortedDictionary;
}
else
{
foreach (string text in queryString.Split(new char[]
{
'&'
}))
{
if (!string.IsNullOrEmpty(text) && !text.StartsWith("oauth_"))
{
if (text.IndexOf('=') > -1)
{
string[] array2 = text.Split(new char[]
{
'='
});
sortedDictionary.Add(array2[0], array2[1]);
}
else
{
sortedDictionary.Add(text, string.Empty);
}
}
}
result = sortedDictionary;
}
return result;
}
// Token: 0x0600002B RID: 43 RVA: 0x000033FC File Offset: 0x000015FC
public static string urlEncode(string value)
{
StringBuilder stringBuilder = new StringBuilder();
foreach (char c in value)
{
if (OAuthManager.unreservedChars.IndexOf(c) != -1)
{
stringBuilder.Append(c);
}
else
{
stringBuilder.Append('%' + string.Format("{0:X2}", (int)c));
}
}
return stringBuilder.ToString();
}
// Token: 0x0600002C RID: 44 RVA: 0x00003484 File Offset: 0x00001684
private static SortedDictionary<string, string> mergePostParamsWithOauthParams(SortedDictionary<string, string> postParams, SortedDictionary<string, string> oAuthParams)
{
SortedDictionary<string, string> sortedDictionary = new SortedDictionary<string, string>();
foreach (KeyValuePair<string, string> keyValuePair in postParams)
{
sortedDictionary.Add(keyValuePair.Key, keyValuePair.Value);
}
foreach (KeyValuePair<string, string> keyValuePair2 in oAuthParams)
{
if (!string.IsNullOrEmpty(keyValuePair2.Value) && !keyValuePair2.Key.EndsWith("secret"))
{
sortedDictionary.Add("oauth_" + keyValuePair2.Key, keyValuePair2.Value);
}
}
return sortedDictionary;
}
// Token: 0x0600002D RID: 45 RVA: 0x00003584 File Offset: 0x00001784
private static string encodeRequestParameters(SortedDictionary<string, string> p)
{
StringBuilder stringBuilder = new StringBuilder();
foreach (KeyValuePair<string, string> keyValuePair in p)
{
if (!string.IsNullOrEmpty(keyValuePair.Value) && !keyValuePair.Key.EndsWith("secret"))
{
stringBuilder.AppendFormat("oauth_{0}=\"{1}\", ", keyValuePair.Key, OAuthManager.urlEncode(keyValuePair.Value));
}
}
return stringBuilder.ToString().TrimEnd(new char[]
{
' '
}).TrimEnd(new char[]
{
','
});
}
// Token: 0x0600002E RID: 46 RVA: 0x00003654 File Offset: 0x00001854
public static byte[] encodePostParameters(SortedDictionary<string, string> p)
{
StringBuilder stringBuilder = new StringBuilder();
foreach (KeyValuePair<string, string> keyValuePair in p)
{
if (!string.IsNullOrEmpty(keyValuePair.Value))
{
stringBuilder.AppendFormat("{0}={1}, ", OAuthManager.urlEncode(keyValuePair.Key), OAuthManager.urlEncode(keyValuePair.Value));
}
}
return Encoding.UTF8.GetBytes(stringBuilder.ToString().TrimEnd(new char[]
{
' '
}).TrimEnd(new char[]
{
','
}));
}
// Token: 0x0600002F RID: 47 RVA: 0x0000371C File Offset: 0x0000191C
public OAuthResponse acquireRequestToken(string uri, string method)
{
this.prepareNewRequest();
string authorizationHeader = this.getAuthorizationHeader(uri, method);
HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(uri);
httpWebRequest.Headers.Add("Authorization", authorizationHeader);
httpWebRequest.Method = method;
OAuthResponse result;
using (HttpWebResponse httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse())
{
using (StreamReader streamReader = new StreamReader(httpWebResponse.GetResponseStream()))
{
OAuthResponse oauthResponse = new OAuthResponse(streamReader.ReadToEnd());
this["token"] = oauthResponse["oauth_token"];
try
{
if (oauthResponse["oauth_token_secret"] != null)
{
this["token_secret"] = oauthResponse["oauth_token_secret"];
}
}
catch
{
}
result = oauthResponse;
}
}
return result;
}
// Token: 0x06000030 RID: 48 RVA: 0x00003820 File Offset: 0x00001A20
public OAuthResponse acquireAccessToken(string uri, string method, string verifier)
{
this.prepareNewRequest();
this._params["verifier"] = verifier;
string authorizationHeader = this.getAuthorizationHeader(uri, method);
HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(uri);
httpWebRequest.Headers.Add("Authorization", authorizationHeader);
httpWebRequest.Method = method;
OAuthResponse result;
using (HttpWebResponse httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse())
{
using (StreamReader streamReader = new StreamReader(httpWebResponse.GetResponseStream()))
{
OAuthResponse oauthResponse = new OAuthResponse(streamReader.ReadToEnd());
this["token"] = oauthResponse["oauth_token"];
this["token_secret"] = oauthResponse["oauth_token_secret"];
result = oauthResponse;
}
}
return result;
}
// Token: 0x06000031 RID: 49 RVA: 0x00003908 File Offset: 0x00001B08
public string generateCredsHeader(string uri, string method, string realm)
{
this.prepareNewRequest();
return this.getAuthorizationHeader(uri, method, realm);
}
// Token: 0x06000032 RID: 50 RVA: 0x0000392C File Offset: 0x00001B2C
public string generateAuthzHeader(string uri, string method)
{
this.prepareNewRequest();
return this.getAuthorizationHeader(uri, method, null);
}
// Token: 0x06000033 RID: 51 RVA: 0x00003950 File Offset: 0x00001B50
private string getAuthorizationHeader(string uri, string method)
{
return this.getAuthorizationHeader(uri, method, null);
}
// Token: 0x06000034 RID: 52 RVA: 0x00003970 File Offset: 0x00001B70
private string getAuthorizationHeader(string uri, string method, string realm)
{
if (string.IsNullOrEmpty(this._params["consumer_key"]))
{
throw new ArgumentNullException("consumer_key");
}
if (string.IsNullOrEmpty(this._params["signature_method"]))
{
throw new ArgumentNullException("signature_method");
}
this.sign(uri, method);
string str = OAuthManager.encodeRequestParameters(this._params);
return (!string.IsNullOrEmpty(realm)) ? (string.Format("OAuth realm=\"{0}\", ", realm) + str) : ("OAuth " + str);
}
// Token: 0x06000035 RID: 53 RVA: 0x00003A10 File Offset: 0x00001C10
private void sign(string uri, string method)
{
string signatureBase = this.getSignatureBase(uri, method);
HashAlgorithm hash = this.getHash();
byte[] bytes = Encoding.ASCII.GetBytes(signatureBase);
byte[] inArray = hash.ComputeHash(bytes);
this["signature"] = Convert.ToBase64String(inArray);
}
// Token: 0x06000036 RID: 54 RVA: 0x00003A54 File Offset: 0x00001C54
private string getSignatureBase(string url, string method)
{
Uri uri = new Uri(url);
string text = string.Format("{0}://{1}", uri.Scheme, uri.Host);
if ((!(uri.Scheme == "http") || uri.Port != 80) && (!(uri.Scheme == "https") || uri.Port != 443))
{
text = text + ":" + uri.Port;
}
text += uri.AbsolutePath;
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.Append(method).Append('&').Append(OAuthManager.urlEncode(text)).Append('&');
SortedDictionary<string, string> sortedDictionary = this.extractQueryParameters(uri.Query);
foreach (KeyValuePair<string, string> keyValuePair in this._params)
{
if (!string.IsNullOrEmpty(this._params[keyValuePair.Key]) && !keyValuePair.Key.EndsWith("_secret") && !keyValuePair.Key.EndsWith("signature"))
{
sortedDictionary.Add("oauth_" + keyValuePair.Key, keyValuePair.Value);
}
}
StringBuilder stringBuilder2 = new StringBuilder();
foreach (KeyValuePair<string, string> keyValuePair2 in sortedDictionary)
{
stringBuilder2.AppendFormat("{0}={1}&", keyValuePair2.Key, keyValuePair2.Value);
}
stringBuilder.Append(OAuthManager.urlEncode(stringBuilder2.ToString().TrimEnd(new char[]
{
'&'
})));
return stringBuilder.ToString();
}
// Token: 0x06000037 RID: 55 RVA: 0x00003C70 File Offset: 0x00001E70
private HashAlgorithm getHash()
{
if (this["signature_method"] != "HMAC-SHA1")
{
throw new NotImplementedException();
}
string s = string.Format("{0}&{1}", OAuthManager.urlEncode(this["consumer_secret"]), OAuthManager.urlEncode(this["token_secret"]));
return new HMACSHA1
{
Key = Encoding.ASCII.GetBytes(s)
};
}
// Token: 0x0400000F RID: 15
private static readonly DateTime _epoch = new DateTime(1970, 1, 1, 0, 0, 0, 0);
// Token: 0x04000010 RID: 16
private SortedDictionary<string, string> _params;
// Token: 0x04000011 RID: 17
private Random _random;
// Token: 0x04000012 RID: 18
private static string unreservedChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.~";
}
}
@@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
namespace Prime31
{
// Token: 0x0200000B RID: 11
public class OAuthResponse
{
// Token: 0x17000005 RID: 5
// (get) Token: 0x06000039 RID: 57 RVA: 0x00003D0C File Offset: 0x00001F0C
// (set) Token: 0x0600003A RID: 58 RVA: 0x00003D26 File Offset: 0x00001F26
public string responseText { get; set; }
// Token: 0x17000006 RID: 6
public string this[string ix]
{
get
{
return this._params[ix];
}
}
// Token: 0x0600003C RID: 60 RVA: 0x00003D54 File Offset: 0x00001F54
public OAuthResponse(string alltext)
{
this.responseText = alltext;
this._params = new Dictionary<string, string>();
string[] array = alltext.Split(new char[]
{
'&'
});
foreach (string text in array)
{
string[] array3 = text.Split(new char[]
{
'='
});
this._params.Add(array3[0], array3[1]);
}
}
// Token: 0x04000014 RID: 20
private Dictionary<string, string> _params;
}
}
@@ -0,0 +1,36 @@
using System;
namespace Prime31
{
// Token: 0x02000006 RID: 6
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
public class P31DeserializeableFieldAttribute : Attribute
{
// Token: 0x06000019 RID: 25 RVA: 0x00002D8C File Offset: 0x00000F8C
public P31DeserializeableFieldAttribute(string key)
{
this.key = key;
}
// Token: 0x0600001A RID: 26 RVA: 0x00002D9C File Offset: 0x00000F9C
public P31DeserializeableFieldAttribute(string key, Type type) : this(key)
{
this.type = type;
}
// Token: 0x0600001B RID: 27 RVA: 0x00002DAD File Offset: 0x00000FAD
public P31DeserializeableFieldAttribute(string key, Type type, bool isCollection) : this(key, type)
{
this.isCollection = isCollection;
}
// Token: 0x0400000C RID: 12
public readonly string key;
// Token: 0x0400000D RID: 13
public readonly bool isCollection;
// Token: 0x0400000E RID: 14
public Type type;
}
}
+85
View File
@@ -0,0 +1,85 @@
using System;
using System.Collections.Generic;
namespace Prime31
{
// Token: 0x02000025 RID: 37
public sealed class P31Error
{
// Token: 0x1700000B RID: 11
// (get) Token: 0x060000D8 RID: 216 RVA: 0x0000816C File Offset: 0x0000636C
// (set) Token: 0x060000D9 RID: 217 RVA: 0x00008186 File Offset: 0x00006386
public string message { get; private set; }
// Token: 0x1700000C RID: 12
// (get) Token: 0x060000DA RID: 218 RVA: 0x00008190 File Offset: 0x00006390
// (set) Token: 0x060000DB RID: 219 RVA: 0x000081AA File Offset: 0x000063AA
public string domain { get; private set; }
// Token: 0x1700000D RID: 13
// (get) Token: 0x060000DC RID: 220 RVA: 0x000081B4 File Offset: 0x000063B4
// (set) Token: 0x060000DD RID: 221 RVA: 0x000081CE File Offset: 0x000063CE
public int code { get; private set; }
// Token: 0x1700000E RID: 14
// (get) Token: 0x060000DE RID: 222 RVA: 0x000081D8 File Offset: 0x000063D8
// (set) Token: 0x060000DF RID: 223 RVA: 0x000081F2 File Offset: 0x000063F2
public Dictionary<string, object> userInfo { get; private set; }
// Token: 0x060000E1 RID: 225 RVA: 0x00008204 File Offset: 0x00006404
public static P31Error errorFromJson(string json)
{
P31Error p31Error = new P31Error();
P31Error result;
if (!json.StartsWith("{"))
{
p31Error.message = json;
p31Error._containsOnlyMessage = true;
result = p31Error;
}
else
{
Dictionary<string, object> dictionary = Json.decode(json) as Dictionary<string, object>;
if (dictionary == null)
{
p31Error.message = "Unknown error";
}
else
{
p31Error.message = ((!dictionary.ContainsKey("message")) ? null : dictionary["message"].ToString());
p31Error.domain = ((!dictionary.ContainsKey("domain")) ? null : dictionary["domain"].ToString());
p31Error.code = ((!dictionary.ContainsKey("code")) ? -1 : int.Parse(dictionary["code"].ToString()));
p31Error.userInfo = ((!dictionary.ContainsKey("userInfo")) ? null : (dictionary["userInfo"] as Dictionary<string, object>));
}
result = p31Error;
}
return result;
}
// Token: 0x060000E2 RID: 226 RVA: 0x00008324 File Offset: 0x00006524
public override string ToString()
{
string result;
if (this._containsOnlyMessage)
{
result = string.Format("[P31Error]: {0}", this.message);
}
else
{
try
{
string input = Json.encode(this);
result = string.Format("[P31Error]: {0}", JsonFormatter.prettyPrint(input));
}
catch (Exception)
{
result = string.Format("[P31Error]: {0}", this.message);
}
}
return result;
}
// Token: 0x0400005E RID: 94
private bool _containsOnlyMessage;
}
}
+248
View File
@@ -0,0 +1,248 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using UnityEngine;
namespace Prime31
{
// Token: 0x02000003 RID: 3
public class P31RestKit
{
// Token: 0x17000001 RID: 1
// (get) Token: 0x06000001 RID: 1 RVA: 0x00002050 File Offset: 0x00000250
// (set) Token: 0x06000002 RID: 2 RVA: 0x000020BC File Offset: 0x000002BC
protected virtual GameObject surrogateGameObject
{
get
{
if (this._surrogateGameObject == null)
{
this._surrogateGameObject = GameObject.Find("P31CoroutineSurrogate");
if (this._surrogateGameObject == null)
{
this._surrogateGameObject = new GameObject("P31CoroutineSurrogate");
UnityEngine.Object.DontDestroyOnLoad(this._surrogateGameObject);
}
}
return this._surrogateGameObject;
}
set
{
this._surrogateGameObject = value;
}
}
// Token: 0x17000002 RID: 2
// (get) Token: 0x06000003 RID: 3 RVA: 0x000020C8 File Offset: 0x000002C8
// (set) Token: 0x06000004 RID: 4 RVA: 0x00002107 File Offset: 0x00000307
protected MonoBehaviour surrogateMonobehaviour
{
get
{
if (this._surrogateMonobehaviour == null)
{
this._surrogateMonobehaviour = this.surrogateGameObject.AddComponent<MonoBehaviour>();
}
return this._surrogateMonobehaviour;
}
set
{
this._surrogateMonobehaviour = value;
}
}
// Token: 0x06000006 RID: 6 RVA: 0x00002120 File Offset: 0x00000320
protected virtual IEnumerator send(string path, HTTPVerb httpVerb, Dictionary<string, object> parameters, Action<string, object> onComplete)
{
if (path.StartsWith("/"))
{
path = path.Substring(1);
}
WWW www = this.processRequest(path, httpVerb, parameters);
yield return www;
if (this.debugRequests)
{
Debug.Log("response error: " + www.error);
Debug.Log("response text: " + www.text);
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.Append("Response Headers:\n");
foreach (KeyValuePair<string, string> keyValuePair in www.responseHeaders)
{
stringBuilder.AppendFormat("{0}: {1}\n", keyValuePair.Key, keyValuePair.Value);
}
Debug.Log(stringBuilder.ToString());
}
if (onComplete != null)
{
this.processResponse(www, onComplete);
}
www.Dispose();
yield break;
}
// Token: 0x06000007 RID: 7 RVA: 0x00002160 File Offset: 0x00000360
protected virtual WWW processRequest(string path, HTTPVerb httpVerb, Dictionary<string, object> parameters)
{
StringBuilder stringBuilder = new StringBuilder(this._baseUrl + path);
bool flag = httpVerb != HTTPVerb.GET;
WWWForm wwwform = (!flag) ? null : new WWWForm();
if (parameters != null && parameters.Count > 0)
{
if (flag)
{
foreach (KeyValuePair<string, object> keyValuePair in parameters)
{
if (keyValuePair.Value is string)
{
wwwform.AddField(keyValuePair.Key, keyValuePair.Value as string);
}
else if (keyValuePair.Value is byte[])
{
wwwform.AddBinaryData(keyValuePair.Key, keyValuePair.Value as byte[]);
}
}
}
else
{
bool flag2 = true;
if (path.Contains("?"))
{
flag2 = false;
}
foreach (KeyValuePair<string, object> keyValuePair2 in parameters)
{
if (keyValuePair2.Value is string)
{
stringBuilder.AppendFormat("{0}{1}={2}", (!flag2) ? "&" : "?", WWW.EscapeURL(keyValuePair2.Key), WWW.EscapeURL(keyValuePair2.Value as string));
flag2 = false;
}
}
}
}
if (this.debugRequests)
{
Debug.Log("url: " + stringBuilder.ToString());
}
return (!flag) ? new WWW(stringBuilder.ToString()) : new WWW(stringBuilder.ToString(), wwwform);
}
// Token: 0x06000008 RID: 8 RVA: 0x0000235C File Offset: 0x0000055C
protected virtual Hashtable headersForRequest(HTTPVerb httpVerb, Dictionary<string, object> parameters)
{
Hashtable result;
if (httpVerb == HTTPVerb.PUT)
{
result = new Hashtable
{
{
"X-HTTP-Method-Override",
"PUT"
}
};
}
else
{
result = null;
}
return result;
}
// Token: 0x06000009 RID: 9 RVA: 0x00002398 File Offset: 0x00000598
protected virtual void processResponse(WWW www, Action<string, object> onComplete)
{
if (www.error != null)
{
onComplete(www.error, null);
}
else if (this.isResponseJson(www))
{
object obj = Json.decode(www.text);
if (obj == null)
{
obj = www.text;
}
onComplete(null, obj);
}
else
{
onComplete(null, www.text);
}
}
// Token: 0x0600000A RID: 10 RVA: 0x0000240C File Offset: 0x0000060C
protected bool isResponseJson(WWW www)
{
bool flag = false;
if (this.forceJsonResponse)
{
flag = true;
}
if (!flag)
{
foreach (KeyValuePair<string, string> keyValuePair in www.responseHeaders)
{
if (keyValuePair.Key.ToLower() == "content-type")
{
if (keyValuePair.Value.ToLower().Contains("/json") || keyValuePair.Value.ToLower().Contains("/javascript"))
{
flag = true;
}
}
}
}
return (!flag || www.text.StartsWith("[") || www.text.StartsWith("{")) && flag;
}
// Token: 0x0600000B RID: 11 RVA: 0x00002510 File Offset: 0x00000710
public void get(string path, Action<string, object> completionHandler)
{
this.get(path, null, completionHandler);
}
// Token: 0x0600000C RID: 12 RVA: 0x0000251C File Offset: 0x0000071C
public void get(string path, Dictionary<string, object> parameters, Action<string, object> completionHandler)
{
this.surrogateMonobehaviour.StartCoroutine(this.send(path, HTTPVerb.GET, parameters, completionHandler));
}
// Token: 0x0600000D RID: 13 RVA: 0x00002535 File Offset: 0x00000735
public void post(string path, Action<string, object> completionHandler)
{
this.post(path, null, completionHandler);
}
// Token: 0x0600000E RID: 14 RVA: 0x00002541 File Offset: 0x00000741
public void post(string path, Dictionary<string, object> parameters, Action<string, object> completionHandler)
{
this.surrogateMonobehaviour.StartCoroutine(this.send(path, HTTPVerb.POST, parameters, completionHandler));
}
// Token: 0x0600000F RID: 15 RVA: 0x0000255A File Offset: 0x0000075A
public void put(string path, Action<string, object> completionHandler)
{
this.put(path, null, completionHandler);
}
// Token: 0x06000010 RID: 16 RVA: 0x00002566 File Offset: 0x00000766
public void put(string path, Dictionary<string, object> parameters, Action<string, object> completionHandler)
{
this.surrogateMonobehaviour.StartCoroutine(this.send(path, HTTPVerb.PUT, parameters, completionHandler));
}
// Token: 0x04000006 RID: 6
protected string _baseUrl;
// Token: 0x04000007 RID: 7
public bool debugRequests = false;
// Token: 0x04000008 RID: 8
protected bool forceJsonResponse;
// Token: 0x04000009 RID: 9
private GameObject _surrogateGameObject;
// Token: 0x0400000A RID: 10
private MonoBehaviour _surrogateMonobehaviour;
}
}
@@ -0,0 +1,80 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{10769494-BEF0-4E49-B36B-1F1685047645}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>Prime31</RootNamespace>
<AssemblyName>P31RestKit</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System">
<HintPath>..\..\..\Desktop\alice hack\IOS\RAW DATA\Payload\aliceheart.app\Data\Managed\System.dll</HintPath>
</Reference>
<Reference Include="System.Core">
<HintPath>..\..\..\Desktop\alice hack\IOS\RAW DATA\Payload\aliceheart.app\Data\Managed\System.Core.dll</HintPath>
</Reference>
<Reference Include="UnityEngine">
<HintPath>..\..\..\Desktop\alice hack\IOS\RAW DATA\Payload\aliceheart.app\Data\Managed\UnityEngine.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<AppDesigner Include="Properties\" />
</ItemGroup>
<ItemGroup>
<Compile Include="AbstractManager.cs" />
<Compile Include="ActionExtensions.cs" />
<Compile Include="DateTimeExtensions.cs" />
<Compile Include="DeserializationExtensions.cs" />
<Compile Include="DTOBase.cs" />
<Compile Include="HTTPVerb.cs" />
<Compile Include="IJsonSerializerStrategy.cs" />
<Compile Include="Json.cs" />
<Compile Include="JsonArray.cs" />
<Compile Include="JsonExtensions.cs" />
<Compile Include="JsonFormatter.cs" />
<Compile Include="JsonObject.cs" />
<Compile Include="MonoBehaviourGUI.cs" />
<Compile Include="OAuthManager.cs" />
<Compile Include="OAuthResponse.cs" />
<Compile Include="P31DeserializeableFieldAttribute.cs" />
<Compile Include="P31Error.cs" />
<Compile Include="P31RestKit.cs" />
<Compile Include="PocoJsonSerializerStrategy.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Reflection\CacheResolver.cs" />
<Compile Include="Reflection\GetHandler.cs" />
<Compile Include="Reflection\MemberMapLoader.cs" />
<Compile Include="Reflection\ReflectionUtils.cs" />
<Compile Include="Reflection\SafeDictionary.cs" />
<Compile Include="Reflection\SetHandler.cs" />
<Compile Include="SimpleJson.cs" />
<Compile Include="StringExtensions.cs" />
<Compile Include="ThreadingCallbackHelper.cs" />
<Compile Include="Utils.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
@@ -0,0 +1,234 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Reflection;
using Prime31.Reflection;
namespace Prime31
{
// Token: 0x0200001C RID: 28
public class PocoJsonSerializerStrategy : IJsonSerializerStrategy
{
// Token: 0x060000AA RID: 170 RVA: 0x0000749C File Offset: 0x0000569C
public PocoJsonSerializerStrategy()
{
this.cacheResolver = new CacheResolver(new MemberMapLoader(this.buildMap));
}
// Token: 0x060000AB RID: 171 RVA: 0x000074C0 File Offset: 0x000056C0
protected virtual void buildMap(Type type, SafeDictionary<string, CacheResolver.MemberMap> memberMaps)
{
foreach (PropertyInfo propertyInfo in type.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic))
{
memberMaps.add(propertyInfo.Name, new CacheResolver.MemberMap(propertyInfo));
}
foreach (FieldInfo fieldInfo in type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic))
{
memberMaps.add(fieldInfo.Name, new CacheResolver.MemberMap(fieldInfo));
}
}
// Token: 0x060000AC RID: 172 RVA: 0x00007544 File Offset: 0x00005744
public virtual bool serializeNonPrimitiveObject(object input, out object output)
{
return this.trySerializeKnownTypes(input, out output) || this.trySerializeUnknownTypes(input, out output);
}
// Token: 0x060000AD RID: 173 RVA: 0x00007574 File Offset: 0x00005774
public virtual object deserializeObject(object value, Type type)
{
object obj = null;
if (value is string)
{
string text = value as string;
if (!string.IsNullOrEmpty(text) && (type == typeof(DateTime) || (ReflectionUtils.isNullableType(type) && Nullable.GetUnderlyingType(type) == typeof(DateTime))))
{
obj = DateTime.ParseExact(text, PocoJsonSerializerStrategy.Iso8601Format, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal | DateTimeStyles.AssumeUniversal);
}
else
{
obj = text;
}
}
else if (value is bool)
{
obj = value;
}
else if (value == null)
{
obj = null;
}
else if ((value is long && type == typeof(long)) || (value is double && type == typeof(double)))
{
obj = value;
}
else
{
if ((!(value is double) || type == typeof(double)) && (!(value is long) || type == typeof(long)))
{
if (value is IDictionary<string, object>)
{
IDictionary<string, object> dictionary = (IDictionary<string, object>)value;
if (ReflectionUtils.isTypeDictionary(type))
{
Type type2 = type.GetGenericArguments()[0];
Type type3 = type.GetGenericArguments()[1];
Type type4 = typeof(Dictionary<, >).MakeGenericType(new Type[]
{
type2,
type3
});
IDictionary dictionary2 = (IDictionary)CacheResolver.getNewInstance(type4);
foreach (KeyValuePair<string, object> keyValuePair in dictionary)
{
dictionary2.Add(keyValuePair.Key, this.deserializeObject(keyValuePair.Value, type3));
}
obj = dictionary2;
}
else
{
obj = CacheResolver.getNewInstance(type);
SafeDictionary<string, CacheResolver.MemberMap> safeDictionary = this.cacheResolver.loadMaps(type);
if (safeDictionary == null)
{
obj = value;
}
else
{
foreach (KeyValuePair<string, CacheResolver.MemberMap> keyValuePair2 in safeDictionary)
{
CacheResolver.MemberMap value2 = keyValuePair2.Value;
if (value2.Setter != null)
{
string key = keyValuePair2.Key;
if (dictionary.ContainsKey(key))
{
object value3 = this.deserializeObject(dictionary[key], value2.Type);
value2.Setter(obj, value3);
}
}
}
}
}
}
else if (value is IList<object>)
{
IList<object> list = (IList<object>)value;
IList list2 = null;
if (type.IsArray)
{
list2 = (IList)Activator.CreateInstance(type, new object[]
{
list.Count
});
int num = 0;
foreach (object value4 in list)
{
list2[num++] = this.deserializeObject(value4, type.GetElementType());
}
}
else if (ReflectionUtils.isTypeGenericeCollectionInterface(type) || typeof(IList).IsAssignableFrom(type))
{
Type type5 = type.GetGenericArguments()[0];
Type type6 = typeof(List<>).MakeGenericType(new Type[]
{
type5
});
list2 = (IList)CacheResolver.getNewInstance(type6);
foreach (object value5 in list)
{
list2.Add(this.deserializeObject(value5, type5));
}
}
obj = list2;
}
return obj;
}
obj = ((!typeof(IConvertible).IsAssignableFrom(type)) ? value : Convert.ChangeType(value, type, CultureInfo.InvariantCulture));
}
object result;
if (ReflectionUtils.isNullableType(type))
{
result = ReflectionUtils.toNullableType(obj, type);
}
else
{
result = obj;
}
return result;
}
// Token: 0x060000AE RID: 174 RVA: 0x000079E0 File Offset: 0x00005BE0
protected virtual object serializeEnum(Enum p)
{
return Convert.ToDouble(p, CultureInfo.InvariantCulture);
}
// Token: 0x060000AF RID: 175 RVA: 0x00007A08 File Offset: 0x00005C08
protected virtual bool trySerializeKnownTypes(object input, out object output)
{
bool result = true;
if (input is DateTime)
{
output = ((DateTime)input).ToUniversalTime().ToString(PocoJsonSerializerStrategy.Iso8601Format[0], CultureInfo.InvariantCulture);
}
else if (input is Guid)
{
output = ((Guid)input).ToString("D");
}
else if (input is Uri)
{
output = input.ToString();
}
else if (input is Enum)
{
output = this.serializeEnum((Enum)input);
}
else
{
result = false;
output = null;
}
return result;
}
// Token: 0x060000B0 RID: 176 RVA: 0x00007AB8 File Offset: 0x00005CB8
protected virtual bool trySerializeUnknownTypes(object input, out object output)
{
output = null;
Type type = input.GetType();
bool result;
if (type.FullName == null)
{
result = false;
}
else
{
IDictionary<string, object> dictionary = new JsonObject();
SafeDictionary<string, CacheResolver.MemberMap> safeDictionary = this.cacheResolver.loadMaps(type);
foreach (KeyValuePair<string, CacheResolver.MemberMap> keyValuePair in safeDictionary)
{
if (keyValuePair.Value.Getter != null)
{
dictionary.Add(keyValuePair.Key, keyValuePair.Value.Getter(input));
}
}
output = dictionary;
result = true;
}
return result;
}
// Token: 0x0400004F RID: 79
internal CacheResolver cacheResolver;
// Token: 0x04000050 RID: 80
private static readonly string[] Iso8601Format = new string[]
{
"yyyy-MM-dd\\THH:mm:ss.FFFFFFF\\Z",
"yyyy-MM-dd\\THH:mm:ss\\Z",
"yyyy-MM-dd\\THH:mm:ssK"
};
}
}
@@ -0,0 +1,12 @@
using System;
using System.Reflection;
using System.Runtime.CompilerServices;
[assembly: AssemblyVersion("2.0.0.0")]
[assembly: AssemblyTitle("P31RestKit")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("desaro")]
[assembly: AssemblyTrademark("")]
@@ -0,0 +1,166 @@
using System;
using System.Reflection;
namespace Prime31.Reflection
{
// Token: 0x02000021 RID: 33
public class CacheResolver
{
// Token: 0x060000C5 RID: 197 RVA: 0x00007D46 File Offset: 0x00005F46
public CacheResolver(MemberMapLoader memberMapLoader)
{
this._memberMapLoader = memberMapLoader;
}
// Token: 0x060000C6 RID: 198 RVA: 0x00007D64 File Offset: 0x00005F64
public static object getNewInstance(Type type)
{
CacheResolver.CtorDelegate ctorDelegate;
object result;
if (CacheResolver.constructorCache.tryGetValue(type, out ctorDelegate))
{
result = ctorDelegate();
}
else
{
ConstructorInfo constructorInfo = type.GetConstructor(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null);
ctorDelegate = (() => constructorInfo.Invoke(null));
CacheResolver.constructorCache.add(type, ctorDelegate);
result = ctorDelegate();
}
return result;
}
// Token: 0x060000C7 RID: 199 RVA: 0x00007DD4 File Offset: 0x00005FD4
public SafeDictionary<string, CacheResolver.MemberMap> loadMaps(Type type)
{
SafeDictionary<string, CacheResolver.MemberMap> result;
SafeDictionary<string, CacheResolver.MemberMap> safeDictionary;
if (type == null || type == typeof(object))
{
result = null;
}
else if (this._memberMapsCache.tryGetValue(type, out safeDictionary))
{
result = safeDictionary;
}
else
{
safeDictionary = new SafeDictionary<string, CacheResolver.MemberMap>();
this._memberMapLoader(type, safeDictionary);
this._memberMapsCache.add(type, safeDictionary);
result = safeDictionary;
}
return result;
}
// Token: 0x060000C8 RID: 200 RVA: 0x00007E44 File Offset: 0x00006044
private static GetHandler createGetHandler(FieldInfo fieldInfo)
{
return (object instance) => fieldInfo.GetValue(instance);
}
// Token: 0x060000C9 RID: 201 RVA: 0x00007E74 File Offset: 0x00006074
private static SetHandler createSetHandler(FieldInfo fieldInfo)
{
SetHandler result;
if (fieldInfo.IsInitOnly || fieldInfo.IsLiteral)
{
result = null;
}
else
{
result = delegate(object instance, object value)
{
fieldInfo.SetValue(instance, value);
};
}
return result;
}
// Token: 0x060000CA RID: 202 RVA: 0x00007ECC File Offset: 0x000060CC
private static GetHandler createGetHandler(PropertyInfo propertyInfo)
{
MethodInfo getMethodInfo = propertyInfo.GetGetMethod(true);
GetHandler result;
if (getMethodInfo == null)
{
result = null;
}
else
{
result = ((object instance) => getMethodInfo.Invoke(instance, Type.EmptyTypes));
}
return result;
}
// Token: 0x060000CB RID: 203 RVA: 0x00007F14 File Offset: 0x00006114
private static SetHandler createSetHandler(PropertyInfo propertyInfo)
{
MethodInfo setMethodInfo = propertyInfo.GetSetMethod(true);
SetHandler result;
if (setMethodInfo == null)
{
result = null;
}
else
{
result = delegate(object instance, object value)
{
setMethodInfo.Invoke(instance, new object[]
{
value
});
};
}
return result;
}
// Token: 0x04000051 RID: 81
private readonly MemberMapLoader _memberMapLoader;
// Token: 0x04000052 RID: 82
private readonly SafeDictionary<Type, SafeDictionary<string, CacheResolver.MemberMap>> _memberMapsCache = new SafeDictionary<Type, SafeDictionary<string, CacheResolver.MemberMap>>();
// Token: 0x04000053 RID: 83
private static readonly SafeDictionary<Type, CacheResolver.CtorDelegate> constructorCache = new SafeDictionary<Type, CacheResolver.CtorDelegate>();
// Token: 0x02000022 RID: 34
// (Invoke) Token: 0x060000CE RID: 206
private delegate object CtorDelegate();
// Token: 0x02000023 RID: 35
public sealed class MemberMap
{
// Token: 0x060000D1 RID: 209 RVA: 0x00007F66 File Offset: 0x00006166
public MemberMap(PropertyInfo propertyInfo)
{
this.MemberInfo = propertyInfo;
this.Type = propertyInfo.PropertyType;
this.Getter = CacheResolver.createGetHandler(propertyInfo);
this.Setter = CacheResolver.createSetHandler(propertyInfo);
}
// Token: 0x060000D2 RID: 210 RVA: 0x00007F9A File Offset: 0x0000619A
public MemberMap(FieldInfo fieldInfo)
{
this.MemberInfo = fieldInfo;
this.Type = fieldInfo.FieldType;
this.Getter = CacheResolver.createGetHandler(fieldInfo);
this.Setter = CacheResolver.createSetHandler(fieldInfo);
}
// Token: 0x04000054 RID: 84
public readonly MemberInfo MemberInfo;
// Token: 0x04000055 RID: 85
public readonly Type Type;
// Token: 0x04000056 RID: 86
public readonly GetHandler Getter;
// Token: 0x04000057 RID: 87
public readonly SetHandler Setter;
}
}
}
@@ -0,0 +1,8 @@
using System;
namespace Prime31.Reflection
{
// Token: 0x0200001E RID: 30
// (Invoke) Token: 0x060000BA RID: 186
public delegate object GetHandler(object source);
}
@@ -0,0 +1,8 @@
using System;
namespace Prime31.Reflection
{
// Token: 0x02000020 RID: 32
// (Invoke) Token: 0x060000C2 RID: 194
public delegate void MemberMapLoader(Type type, SafeDictionary<string, CacheResolver.MemberMap> memberMaps);
}
@@ -0,0 +1,90 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Reflection;
namespace Prime31.Reflection
{
// Token: 0x0200001D RID: 29
public class ReflectionUtils
{
// Token: 0x060000B3 RID: 179 RVA: 0x00007BAC File Offset: 0x00005DAC
public static Attribute getAttribute(MemberInfo info, Type type)
{
Attribute result;
if (info == null || type == null || !Attribute.IsDefined(info, type))
{
result = null;
}
else
{
result = Attribute.GetCustomAttribute(info, type);
}
return result;
}
// Token: 0x060000B4 RID: 180 RVA: 0x00007BE8 File Offset: 0x00005DE8
public static Attribute getAttribute(Type objectType, Type attributeType)
{
Attribute result;
if (objectType == null || attributeType == null || !Attribute.IsDefined(objectType, attributeType))
{
result = null;
}
else
{
result = Attribute.GetCustomAttribute(objectType, attributeType);
}
return result;
}
// Token: 0x060000B5 RID: 181 RVA: 0x00007C24 File Offset: 0x00005E24
public static bool isTypeGenericeCollectionInterface(Type type)
{
bool result;
if (!type.IsGenericType)
{
result = false;
}
else
{
Type genericTypeDefinition = type.GetGenericTypeDefinition();
result = (genericTypeDefinition == typeof(IList<>) || genericTypeDefinition == typeof(ICollection<>) || genericTypeDefinition == typeof(IEnumerable<>));
}
return result;
}
// Token: 0x060000B6 RID: 182 RVA: 0x00007C84 File Offset: 0x00005E84
public static bool isTypeDictionary(Type type)
{
bool result;
if (typeof(IDictionary).IsAssignableFrom(type))
{
result = true;
}
else if (!type.IsGenericType)
{
result = false;
}
else
{
Type genericTypeDefinition = type.GetGenericTypeDefinition();
result = (genericTypeDefinition == typeof(IDictionary<, >));
}
return result;
}
// Token: 0x060000B7 RID: 183 RVA: 0x00007CDC File Offset: 0x00005EDC
public static bool isNullableType(Type type)
{
return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>);
}
// Token: 0x060000B8 RID: 184 RVA: 0x00007D14 File Offset: 0x00005F14
public static object toNullableType(object obj, Type nullableType)
{
return (obj != null) ? Convert.ChangeType(obj, Nullable.GetUnderlyingType(nullableType), CultureInfo.InvariantCulture) : null;
}
}
}
@@ -0,0 +1,49 @@
using System;
using System.Collections.Generic;
namespace Prime31.Reflection
{
// Token: 0x02000024 RID: 36
public class SafeDictionary<TKey, TValue>
{
// Token: 0x1700000A RID: 10
public TValue this[TKey key]
{
get
{
return this._dictionary[key];
}
}
// Token: 0x060000D5 RID: 213 RVA: 0x000080D0 File Offset: 0x000062D0
public bool tryGetValue(TKey key, out TValue value)
{
return this._dictionary.TryGetValue(key, out value);
}
// Token: 0x060000D6 RID: 214 RVA: 0x000080F4 File Offset: 0x000062F4
public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator()
{
return ((IEnumerable<KeyValuePair<TKey, TValue>>)this._dictionary).GetEnumerator();
}
// Token: 0x060000D7 RID: 215 RVA: 0x00008114 File Offset: 0x00006314
public void add(TKey key, TValue value)
{
object padlock = this._padlock;
lock (padlock)
{
if (!this._dictionary.ContainsKey(key))
{
this._dictionary.Add(key, value);
}
}
}
// Token: 0x04000058 RID: 88
private readonly object _padlock = new object();
// Token: 0x04000059 RID: 89
private readonly Dictionary<TKey, TValue> _dictionary = new Dictionary<TKey, TValue>();
}
}
@@ -0,0 +1,8 @@
using System;
namespace Prime31.Reflection
{
// Token: 0x0200001F RID: 31
// (Invoke) Token: 0x060000BE RID: 190
public delegate void SetHandler(object source, object value);
}
+811
View File
@@ -0,0 +1,811 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
namespace Prime31
{
// Token: 0x0200001A RID: 26
public class SimpleJson
{
// Token: 0x17000008 RID: 8
// (get) Token: 0x0600008D RID: 141 RVA: 0x00006384 File Offset: 0x00004584
// (set) Token: 0x0600008E RID: 142 RVA: 0x000063B0 File Offset: 0x000045B0
public static IJsonSerializerStrategy currentJsonSerializerStrategy
{
get
{
IJsonSerializerStrategy result;
if ((result = SimpleJson._currentJsonSerializerStrategy) == null)
{
result = (SimpleJson._currentJsonSerializerStrategy = SimpleJson.pocoJsonSerializerStrategy);
}
return result;
}
set
{
SimpleJson.currentJsonSerializerStrategy = value;
}
}
// Token: 0x17000009 RID: 9
// (get) Token: 0x0600008F RID: 143 RVA: 0x000063BC File Offset: 0x000045BC
public static PocoJsonSerializerStrategy pocoJsonSerializerStrategy
{
get
{
PocoJsonSerializerStrategy result;
if ((result = SimpleJson._pocoJsonSerializerStrategy) == null)
{
result = (SimpleJson._pocoJsonSerializerStrategy = new PocoJsonSerializerStrategy());
}
return result;
}
}
// Token: 0x06000091 RID: 145 RVA: 0x000063F0 File Offset: 0x000045F0
public static string encode(object obj)
{
StringBuilder stringBuilder = new StringBuilder(2000);
bool flag = SimpleJson.serializeValue(SimpleJson.currentJsonSerializerStrategy, obj, stringBuilder);
return (!flag) ? null : stringBuilder.ToString();
}
// Token: 0x06000092 RID: 146 RVA: 0x00006430 File Offset: 0x00004630
public static bool tryDeserializeObject(string json, out object obj)
{
bool result = true;
if (json != null)
{
char[] json2 = json.ToCharArray();
int num = 0;
obj = SimpleJson.parseValue(json2, ref num, ref result);
}
else
{
obj = null;
}
return result;
}
// Token: 0x06000093 RID: 147 RVA: 0x00006470 File Offset: 0x00004670
public static object decode(string json)
{
object obj;
object result;
if (SimpleJson.tryDeserializeObject(json, out obj))
{
result = obj;
}
else
{
Utils.logObject("Something went wrong deserializing the json. We got a null return. Here is the json we tried to deserialize: " + json);
result = null;
}
return result;
}
// Token: 0x06000094 RID: 148 RVA: 0x000064B0 File Offset: 0x000046B0
private static object decode(string json, Type type)
{
return SimpleJson.decode(json, type, null);
}
// Token: 0x06000095 RID: 149 RVA: 0x000064D0 File Offset: 0x000046D0
public static T decode<T>(string json)
{
return (T)((object)SimpleJson.decode(json, typeof(T)));
}
// Token: 0x06000096 RID: 150 RVA: 0x000064FC File Offset: 0x000046FC
public static T decode<T>(string json, string rootElement) where T : new()
{
return (T)((object)SimpleJson.decode(json, typeof(T), rootElement));
}
// Token: 0x06000097 RID: 151 RVA: 0x00006528 File Offset: 0x00004728
private static object decode(string json, Type type, string rootElement = null)
{
object obj = SimpleJson.decode(json);
object result;
if (type == null || (obj != null && obj.GetType().IsAssignableFrom(type)))
{
result = obj;
}
else
{
if (rootElement != null)
{
if (obj is JsonObject)
{
JsonObject jsonObject = obj as JsonObject;
if (jsonObject.ContainsKey(rootElement))
{
obj = jsonObject[rootElement];
}
else
{
Utils.logObject(string.Format("A rootElement was requested ({0}) but does not exist in the decoded Dictionary", rootElement));
}
}
else
{
Utils.logObject(string.Format("A rootElement was requested ({0}) but the decoded object is not a Dictionary. It is a {1}", rootElement, obj.GetType()));
}
}
result = SimpleJson.currentJsonSerializerStrategy.deserializeObject(obj, type);
}
return result;
}
// Token: 0x06000098 RID: 152 RVA: 0x000065D8 File Offset: 0x000047D8
public static T decodeObject<T>(object jsonObject, string rootElement = null)
{
Type typeFromHandle = typeof(T);
T result;
if (typeFromHandle == null || (jsonObject != null && jsonObject.GetType().IsAssignableFrom(typeFromHandle)))
{
result = (T)((object)jsonObject);
}
else
{
if (rootElement != null)
{
if (jsonObject is Dictionary<string, object>)
{
Dictionary<string, object> dictionary = jsonObject as Dictionary<string, object>;
if (dictionary.ContainsKey(rootElement))
{
jsonObject = dictionary[rootElement];
}
else
{
Utils.logObject(string.Format("A rootElement was requested ({0}) but does not exist in the decoded Dictionary", rootElement));
}
}
else
{
Utils.logObject(string.Format("A rootElement was requested ({0}) but the decoded object is not a Dictionary. It is a {1}", rootElement, jsonObject.GetType()));
}
}
result = (T)((object)SimpleJson.currentJsonSerializerStrategy.deserializeObject(jsonObject, typeFromHandle));
}
return result;
}
// Token: 0x06000099 RID: 153 RVA: 0x00006698 File Offset: 0x00004898
protected static IDictionary<string, object> parseObject(char[] json, ref int index, ref bool success)
{
IDictionary<string, object> dictionary = new JsonObject();
SimpleJson.nextToken(json, ref index);
bool flag = false;
while (!flag)
{
int num = SimpleJson.lookAhead(json, index);
if (num != 0)
{
if (num == 6)
{
SimpleJson.nextToken(json, ref index);
}
else
{
if (num == 2)
{
SimpleJson.nextToken(json, ref index);
return dictionary;
}
string key = SimpleJson.parseString(json, ref index, ref success);
if (!success)
{
success = false;
return null;
}
num = SimpleJson.nextToken(json, ref index);
if (num != 5)
{
success = false;
return null;
}
object value = SimpleJson.parseValue(json, ref index, ref success);
if (!success)
{
success = false;
return null;
}
dictionary[key] = value;
}
continue;
}
success = false;
return null;
}
return dictionary;
}
// Token: 0x0600009A RID: 154 RVA: 0x00006770 File Offset: 0x00004970
protected static JsonArray parseArray(char[] json, ref int index, ref bool success)
{
JsonArray jsonArray = new JsonArray();
SimpleJson.nextToken(json, ref index);
bool flag = false;
while (!flag)
{
int num = SimpleJson.lookAhead(json, index);
if (num != 0)
{
if (num == 6)
{
SimpleJson.nextToken(json, ref index);
}
else
{
if (num == 4)
{
SimpleJson.nextToken(json, ref index);
break;
}
object item = SimpleJson.parseValue(json, ref index, ref success);
if (!success)
{
return null;
}
jsonArray.Add(item);
}
continue;
}
success = false;
return null;
}
return jsonArray;
}
// Token: 0x0600009B RID: 155 RVA: 0x00006808 File Offset: 0x00004A08
protected static object parseValue(char[] json, ref int index, ref bool success)
{
switch (SimpleJson.lookAhead(json, index))
{
case 1:
return SimpleJson.parseObject(json, ref index, ref success);
case 3:
return SimpleJson.parseArray(json, ref index, ref success);
case 7:
return SimpleJson.parseString(json, ref index, ref success);
case 8:
return SimpleJson.parseNumber(json, ref index, ref success);
case 9:
SimpleJson.nextToken(json, ref index);
return true;
case 10:
SimpleJson.nextToken(json, ref index);
return false;
case 11:
SimpleJson.nextToken(json, ref index);
return null;
}
success = false;
return null;
}
// Token: 0x0600009C RID: 156 RVA: 0x000068DC File Offset: 0x00004ADC
protected static string parseString(char[] json, ref int index, ref bool success)
{
StringBuilder stringBuilder = new StringBuilder(2000);
SimpleJson.eatWhitespace(json, ref index);
char c = json[index++];
bool flag = false;
while (!flag)
{
if (index == json.Length)
{
break;
}
c = json[index++];
if (c == '"')
{
flag = true;
break;
}
if (c == '\\')
{
if (index == json.Length)
{
break;
}
c = json[index++];
if (c == '"')
{
stringBuilder.Append('"');
}
else if (c == '\\')
{
stringBuilder.Append('\\');
}
else if (c == '/')
{
stringBuilder.Append('/');
}
else if (c == 'b')
{
stringBuilder.Append('\b');
}
else if (c == 'f')
{
stringBuilder.Append('\f');
}
else if (c == 'n')
{
stringBuilder.Append('\n');
}
else if (c == 'r')
{
stringBuilder.Append('\r');
}
else if (c == 't')
{
stringBuilder.Append('\t');
}
else if (c == 'u')
{
int num = json.Length - index;
if (num >= 4)
{
uint num2;
string result;
if (!(success = uint.TryParse(new string(json, index, 4), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out num2)))
{
result = "";
}
else
{
if (55296U > num2 || num2 > 56319U)
{
stringBuilder.Append(char.ConvertFromUtf32((int)num2));
index += 4;
continue;
}
index += 4;
num = json.Length - index;
if (num >= 6)
{
uint num3;
if (new string(json, index, 2) == "\\u" && uint.TryParse(new string(json, index + 2, 4), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out num3))
{
if (56320U <= num3 && num3 <= 57343U)
{
stringBuilder.Append((char)num2);
stringBuilder.Append((char)num3);
index += 6;
continue;
}
}
}
success = false;
result = "";
}
return result;
}
break;
}
}
else
{
stringBuilder.Append(c);
}
}
if (!flag)
{
success = false;
return null;
}
return stringBuilder.ToString();
}
// Token: 0x0600009D RID: 157 RVA: 0x00006B64 File Offset: 0x00004D64
protected static object parseNumber(char[] json, ref int index, ref bool success)
{
SimpleJson.eatWhitespace(json, ref index);
int lastIndexOfNumber = SimpleJson.getLastIndexOfNumber(json, index);
int length = lastIndexOfNumber - index + 1;
string text = new string(json, index, length);
object result;
if (text.IndexOf(".", StringComparison.OrdinalIgnoreCase) != -1 || text.IndexOf("e", StringComparison.OrdinalIgnoreCase) != -1)
{
double num;
success = double.TryParse(new string(json, index, length), NumberStyles.Any, CultureInfo.InvariantCulture, out num);
result = num;
}
else
{
long num2;
success = long.TryParse(new string(json, index, length), NumberStyles.Any, CultureInfo.InvariantCulture, out num2);
result = num2;
}
index = lastIndexOfNumber + 1;
return result;
}
// Token: 0x0600009E RID: 158 RVA: 0x00006C18 File Offset: 0x00004E18
protected static int getLastIndexOfNumber(char[] json, int index)
{
int i;
for (i = index; i < json.Length; i++)
{
if ("0123456789+-.eE".IndexOf(json[i]) == -1)
{
break;
}
}
return i - 1;
}
// Token: 0x0600009F RID: 159 RVA: 0x00006C5C File Offset: 0x00004E5C
protected static void eatWhitespace(char[] json, ref int index)
{
while (index < json.Length)
{
if (" \t\n\r\b\f".IndexOf(json[index]) == -1)
{
break;
}
index++;
}
}
// Token: 0x060000A0 RID: 160 RVA: 0x00006C90 File Offset: 0x00004E90
protected static int lookAhead(char[] json, int index)
{
int num = index;
return SimpleJson.nextToken(json, ref num);
}
// Token: 0x060000A1 RID: 161 RVA: 0x00006CB0 File Offset: 0x00004EB0
protected static int nextToken(char[] json, ref int index)
{
SimpleJson.eatWhitespace(json, ref index);
int result;
if (index == json.Length)
{
result = 0;
}
else
{
char c = json[index];
index++;
switch (c)
{
case ',':
result = 6;
break;
case '-':
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
result = 8;
break;
default:
switch (c)
{
case '[':
result = 3;
break;
default:
switch (c)
{
case '{':
result = 1;
break;
default:
if (c != '"')
{
index--;
int num = json.Length - index;
if (num >= 5)
{
if (json[index] == 'f' && json[index + 1] == 'a' && json[index + 2] == 'l' && json[index + 3] == 's' && json[index + 4] == 'e')
{
index += 5;
result = 10;
break;
}
}
if (num >= 4)
{
if (json[index] == 't' && json[index + 1] == 'r' && json[index + 2] == 'u' && json[index + 3] == 'e')
{
index += 4;
result = 9;
break;
}
}
if (num >= 4)
{
if (json[index] == 'n' && json[index + 1] == 'u' && json[index + 2] == 'l' && json[index + 3] == 'l')
{
index += 4;
result = 11;
break;
}
}
result = 0;
}
else
{
result = 7;
}
break;
case '}':
result = 2;
break;
}
break;
case ']':
result = 4;
break;
}
break;
case ':':
result = 5;
break;
}
}
return result;
}
// Token: 0x060000A2 RID: 162 RVA: 0x00006E98 File Offset: 0x00005098
protected static bool serializeValue(IJsonSerializerStrategy jsonSerializerStrategy, object value, StringBuilder builder)
{
bool flag = true;
if (value is string)
{
flag = SimpleJson.serializeString((string)value, builder);
}
else if (value is IDictionary<string, object>)
{
IDictionary<string, object> dictionary = (IDictionary<string, object>)value;
flag = SimpleJson.serializeObject(jsonSerializerStrategy, dictionary.Keys, dictionary.Values, builder);
}
else if (value is IDictionary<string, string>)
{
IDictionary<string, string> dictionary2 = (IDictionary<string, string>)value;
flag = SimpleJson.serializeObject(jsonSerializerStrategy, dictionary2.Keys, dictionary2.Values, builder);
}
else if (value is IDictionary)
{
IDictionary dictionary3 = (IDictionary)value;
flag = SimpleJson.serializeObject(jsonSerializerStrategy, dictionary3.Keys, dictionary3.Values, builder);
}
else if (value is IEnumerable)
{
flag = SimpleJson.serializeArray(jsonSerializerStrategy, (IEnumerable)value, builder);
}
else if (SimpleJson.isNumeric(value))
{
flag = SimpleJson.serializeNumber(value, builder);
}
else if (value is bool)
{
builder.Append((!(bool)value) ? "false" : "true");
}
else if (value == null)
{
builder.Append("null");
}
else
{
object value2;
flag = jsonSerializerStrategy.serializeNonPrimitiveObject(value, out value2);
if (flag)
{
SimpleJson.serializeValue(jsonSerializerStrategy, value2, builder);
}
}
return flag;
}
// Token: 0x060000A3 RID: 163 RVA: 0x00006FF0 File Offset: 0x000051F0
protected static bool serializeObject(IJsonSerializerStrategy jsonSerializerStrategy, IEnumerable keys, IEnumerable values, StringBuilder builder)
{
builder.Append("{");
IEnumerator enumerator = keys.GetEnumerator();
IEnumerator enumerator2 = values.GetEnumerator();
bool flag = true;
while (enumerator.MoveNext() && enumerator2.MoveNext())
{
object obj = enumerator.Current;
object value = enumerator2.Current;
if (!flag)
{
builder.Append(",");
}
if (obj is string)
{
SimpleJson.serializeString((string)obj, builder);
}
else if (!SimpleJson.serializeValue(jsonSerializerStrategy, value, builder))
{
return false;
}
builder.Append(":");
if (SimpleJson.serializeValue(jsonSerializerStrategy, value, builder))
{
flag = false;
continue;
}
return false;
}
builder.Append("}");
return true;
}
// Token: 0x060000A4 RID: 164 RVA: 0x000070C8 File Offset: 0x000052C8
protected static bool serializeArray(IJsonSerializerStrategy jsonSerializerStrategy, IEnumerable anArray, StringBuilder builder)
{
builder.Append("[");
bool flag = true;
IEnumerator enumerator = anArray.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
object value = enumerator.Current;
if (!flag)
{
builder.Append(",");
}
if (!SimpleJson.serializeValue(jsonSerializerStrategy, value, builder))
{
return false;
}
flag = false;
}
}
finally
{
IDisposable disposable;
if ((disposable = (enumerator as IDisposable)) != null)
{
disposable.Dispose();
}
}
builder.Append("]");
return true;
}
// Token: 0x060000A5 RID: 165 RVA: 0x0000716C File Offset: 0x0000536C
protected static bool serializeString(string aString, StringBuilder builder)
{
builder.Append("\"");
foreach (char c in aString.ToCharArray())
{
if (c == '"')
{
builder.Append("\\\"");
}
else if (c == '\\')
{
builder.Append("\\\\");
}
else if (c == '\b')
{
builder.Append("\\b");
}
else if (c == '\f')
{
builder.Append("\\f");
}
else if (c == '\n')
{
builder.Append("\\n");
}
else if (c == '\r')
{
builder.Append("\\r");
}
else if (c == '\t')
{
builder.Append("\\t");
}
else
{
builder.Append(c);
}
}
builder.Append("\"");
return true;
}
// Token: 0x060000A6 RID: 166 RVA: 0x00007274 File Offset: 0x00005474
protected static bool serializeNumber(object number, StringBuilder builder)
{
if (number is long)
{
builder.Append(((long)number).ToString(CultureInfo.InvariantCulture));
}
else if (number is ulong)
{
builder.Append(((ulong)number).ToString(CultureInfo.InvariantCulture));
}
else if (number is int)
{
builder.Append(((int)number).ToString(CultureInfo.InvariantCulture));
}
else if (number is uint)
{
builder.Append(((uint)number).ToString(CultureInfo.InvariantCulture));
}
else if (number is decimal)
{
builder.Append(((decimal)number).ToString(CultureInfo.InvariantCulture));
}
else if (number is float)
{
builder.Append(((float)number).ToString(CultureInfo.InvariantCulture));
}
else
{
builder.Append(Convert.ToDouble(number, CultureInfo.InvariantCulture).ToString("r", CultureInfo.InvariantCulture));
}
return true;
}
// Token: 0x060000A7 RID: 167 RVA: 0x000073C0 File Offset: 0x000055C0
protected static bool isNumeric(object value)
{
return value is sbyte || value is byte || value is short || value is ushort || value is int || value is uint || value is long || value is ulong || value is float || value is double || value is decimal;
}
// Token: 0x04000040 RID: 64
private const int TOKEN_NONE = 0;
// Token: 0x04000041 RID: 65
private const int TOKEN_CURLY_OPEN = 1;
// Token: 0x04000042 RID: 66
private const int TOKEN_CURLY_CLOSE = 2;
// Token: 0x04000043 RID: 67
private const int TOKEN_SQUARED_OPEN = 3;
// Token: 0x04000044 RID: 68
private const int TOKEN_SQUARED_CLOSE = 4;
// Token: 0x04000045 RID: 69
private const int TOKEN_COLON = 5;
// Token: 0x04000046 RID: 70
private const int TOKEN_COMMA = 6;
// Token: 0x04000047 RID: 71
private const int TOKEN_STRING = 7;
// Token: 0x04000048 RID: 72
private const int TOKEN_NUMBER = 8;
// Token: 0x04000049 RID: 73
private const int TOKEN_TRUE = 9;
// Token: 0x0400004A RID: 74
private const int TOKEN_FALSE = 10;
// Token: 0x0400004B RID: 75
private const int TOKEN_NULL = 11;
// Token: 0x0400004C RID: 76
private const int BUILDER_CAPACITY = 2000;
// Token: 0x0400004D RID: 77
private static IJsonSerializerStrategy _currentJsonSerializerStrategy;
// Token: 0x0400004E RID: 78
private static PocoJsonSerializerStrategy _pocoJsonSerializerStrategy;
}
}
@@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
namespace Prime31
{
// Token: 0x02000009 RID: 9
public static class StringExtensions
{
// Token: 0x06000022 RID: 34 RVA: 0x00002FC8 File Offset: 0x000011C8
public static Dictionary<string, string> parseQueryString(this string self)
{
Dictionary<string, string> dictionary = new Dictionary<string, string>();
string[] array = self.Split(new char[]
{
'?'
});
string[] array2;
if (array.Length != 2)
{
array2 = self.Split(new char[]
{
'&'
});
}
else
{
array2 = array[1].Split(new char[]
{
'&'
});
}
foreach (string text in array2)
{
string[] array4 = text.Split(new char[]
{
'='
});
dictionary.Add(array4[0], array4[1]);
}
return dictionary;
}
}
}
@@ -0,0 +1,55 @@
using System;
using System.Collections.Generic;
using UnityEngine;
namespace Prime31
{
// Token: 0x0200000E RID: 14
public class ThreadingCallbackHelper : MonoBehaviour
{
// Token: 0x06000054 RID: 84 RVA: 0x00004578 File Offset: 0x00002778
public void addActionToQueue(Action action)
{
object actions = this._actions;
lock (actions)
{
this._actions.Add(action);
}
}
// Token: 0x06000055 RID: 85 RVA: 0x000045BC File Offset: 0x000027BC
private void Update()
{
object actions = this._actions;
lock (actions)
{
this._currentActions.AddRange(this._actions);
this._actions.Clear();
}
for (int i = 0; i < this._currentActions.Count; i++)
{
this._currentActions[i]();
}
this._currentActions.Clear();
}
// Token: 0x06000056 RID: 86 RVA: 0x0000464C File Offset: 0x0000284C
public void disableIfEmpty()
{
object actions = this._actions;
lock (actions)
{
if (this._actions.Count == 0)
{
base.enabled = false;
}
}
}
// Token: 0x04000022 RID: 34
private List<Action> _actions = new List<Action>();
// Token: 0x04000023 RID: 35
private List<Action> _currentActions = new List<Action>();
}
}
+64
View File
@@ -0,0 +1,64 @@
using System;
using System.Text;
using UnityEngine;
namespace Prime31
{
// Token: 0x02000004 RID: 4
public static class Utils
{
// Token: 0x17000003 RID: 3
// (get) Token: 0x06000011 RID: 17 RVA: 0x00002774 File Offset: 0x00000974
private static System.Random random
{
get
{
if (Utils._random == null)
{
Utils._random = new System.Random();
}
return Utils._random;
}
}
// Token: 0x06000012 RID: 18 RVA: 0x000027A4 File Offset: 0x000009A4
public static string randomString(int size = 38)
{
StringBuilder stringBuilder = new StringBuilder();
for (int i = 0; i < size; i++)
{
char value = Convert.ToChar(Convert.ToInt32(Math.Floor(26.0 * Utils.random.NextDouble() + 65.0)));
stringBuilder.Append(value);
}
return stringBuilder.ToString();
}
// Token: 0x06000013 RID: 19 RVA: 0x00002810 File Offset: 0x00000A10
public static void logObject(object obj)
{
string json = Json.encode(obj);
Utils.prettyPrintJson(json);
}
// Token: 0x06000014 RID: 20 RVA: 0x0000282C File Offset: 0x00000A2C
public static void prettyPrintJson(string json)
{
string text = string.Empty;
if (json != null)
{
text = JsonFormatter.prettyPrint(json);
}
try
{
Debug.Log(text);
}
catch (Exception)
{
Console.WriteLine(text);
}
}
// Token: 0x0400000B RID: 11
private static System.Random _random;
}
}