This commit is contained in:
niko
2026-06-04 11:42:34 +02:00
parent f39ba70a9f
commit e720b98cd1
7488 changed files with 2493818 additions and 0 deletions
@@ -0,0 +1,16 @@
using System;
using System.CodeDom.Compiler;
namespace SimpleJson
{
// Token: 0x020002E4 RID: 740
[GeneratedCode("simple-json", "1.0.0")]
internal interface IJsonSerializerStrategy
{
// Token: 0x060030AD RID: 12461
bool TrySerializeNonPrimitiveObject(object input, out object output);
// Token: 0x060030AE RID: 12462
object DeserializeObject(object value, Type type);
}
}
+30
View File
@@ -0,0 +1,30 @@
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.ComponentModel;
namespace SimpleJson
{
// Token: 0x020002E1 RID: 737
[GeneratedCode("simple-json", "1.0.0")]
[EditorBrowsable(EditorBrowsableState.Never)]
internal class JsonArray : List<object>
{
// Token: 0x06003078 RID: 12408 RVA: 0x00046BA4 File Offset: 0x00044DA4
public JsonArray()
{
}
// Token: 0x06003079 RID: 12409 RVA: 0x00046BB0 File Offset: 0x00044DB0
public JsonArray(int capacity)
: base(capacity)
{
}
// Token: 0x0600307A RID: 12410 RVA: 0x00046BBC File Offset: 0x00044DBC
public override string ToString()
{
return SimpleJson.SerializeObject(this) ?? string.Empty;
}
}
}
+197
View File
@@ -0,0 +1,197 @@
using System;
using System.CodeDom.Compiler;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
namespace SimpleJson
{
// Token: 0x020002E2 RID: 738
[GeneratedCode("simple-json", "1.0.0")]
[EditorBrowsable(EditorBrowsableState.Never)]
internal class JsonObject : IDictionary<string, object>, ICollection<KeyValuePair<string, object>>, IEnumerable<KeyValuePair<string, object>>, IEnumerable
{
// Token: 0x0600307B RID: 12411 RVA: 0x00046BE4 File Offset: 0x00044DE4
public JsonObject()
{
this._members = new Dictionary<string, object>();
}
// Token: 0x0600307C RID: 12412 RVA: 0x00046BF8 File Offset: 0x00044DF8
public JsonObject(IEqualityComparer<string> comparer)
{
this._members = new Dictionary<string, object>(comparer);
}
// Token: 0x17000AFF RID: 2815
public object this[int index]
{
get
{
return JsonObject.GetAtIndex(this._members, index);
}
}
// Token: 0x0600307E RID: 12414 RVA: 0x00046C34 File Offset: 0x00044E34
internal static object GetAtIndex(IDictionary<string, object> obj, int index)
{
if (obj == null)
{
throw new ArgumentNullException("obj");
}
if (index >= obj.Count)
{
throw new ArgumentOutOfRangeException("index");
}
int num = 0;
foreach (KeyValuePair<string, object> keyValuePair in obj)
{
if (num++ == index)
{
return keyValuePair.Value;
}
}
return null;
}
// Token: 0x0600307F RID: 12415 RVA: 0x00046CD0 File Offset: 0x00044ED0
public void Add(string key, object value)
{
this._members.Add(key, value);
}
// Token: 0x06003080 RID: 12416 RVA: 0x00046CE0 File Offset: 0x00044EE0
public bool ContainsKey(string key)
{
return this._members.ContainsKey(key);
}
// Token: 0x17000B00 RID: 2816
// (get) Token: 0x06003081 RID: 12417 RVA: 0x00046D04 File Offset: 0x00044F04
public ICollection<string> Keys
{
get
{
return this._members.Keys;
}
}
// Token: 0x06003082 RID: 12418 RVA: 0x00046D24 File Offset: 0x00044F24
public bool Remove(string key)
{
return this._members.Remove(key);
}
// Token: 0x06003083 RID: 12419 RVA: 0x00046D48 File Offset: 0x00044F48
public bool TryGetValue(string key, out object value)
{
return this._members.TryGetValue(key, out value);
}
// Token: 0x17000B01 RID: 2817
// (get) Token: 0x06003084 RID: 12420 RVA: 0x00046D6C File Offset: 0x00044F6C
public ICollection<object> Values
{
get
{
return this._members.Values;
}
}
// Token: 0x17000B02 RID: 2818
public object this[string key]
{
get
{
return this._members[key];
}
set
{
this._members[key] = value;
}
}
// Token: 0x06003087 RID: 12423 RVA: 0x00046DC0 File Offset: 0x00044FC0
public void Add(KeyValuePair<string, object> item)
{
this._members.Add(item.Key, item.Value);
}
// Token: 0x06003088 RID: 12424 RVA: 0x00046DDC File Offset: 0x00044FDC
public void Clear()
{
this._members.Clear();
}
// Token: 0x06003089 RID: 12425 RVA: 0x00046DEC File Offset: 0x00044FEC
public bool Contains(KeyValuePair<string, object> item)
{
return this._members.ContainsKey(item.Key) && this._members[item.Key] == item.Value;
}
// Token: 0x0600308A RID: 12426 RVA: 0x00046E38 File Offset: 0x00045038
public void CopyTo(KeyValuePair<string, object>[] array, int arrayIndex)
{
if (array == null)
{
throw new ArgumentNullException("array");
}
int num = this.Count;
foreach (KeyValuePair<string, object> keyValuePair in this)
{
array[arrayIndex++] = keyValuePair;
if (--num <= 0)
{
break;
}
}
}
// Token: 0x17000B03 RID: 2819
// (get) Token: 0x0600308B RID: 12427 RVA: 0x00046EC4 File Offset: 0x000450C4
public int Count
{
get
{
return this._members.Count;
}
}
// Token: 0x17000B04 RID: 2820
// (get) Token: 0x0600308C RID: 12428 RVA: 0x00046EE4 File Offset: 0x000450E4
public bool IsReadOnly
{
get
{
return false;
}
}
// Token: 0x0600308D RID: 12429 RVA: 0x00046EFC File Offset: 0x000450FC
public bool Remove(KeyValuePair<string, object> item)
{
return this._members.Remove(item.Key);
}
// Token: 0x0600308E RID: 12430 RVA: 0x00046F24 File Offset: 0x00045124
public IEnumerator<KeyValuePair<string, object>> GetEnumerator()
{
return this._members.GetEnumerator();
}
// Token: 0x0600308F RID: 12431 RVA: 0x00046F4C File Offset: 0x0004514C
IEnumerator IEnumerable.GetEnumerator()
{
return this._members.GetEnumerator();
}
// Token: 0x06003090 RID: 12432 RVA: 0x00046F74 File Offset: 0x00045174
public override string ToString()
{
return SimpleJson.SerializeObject(this);
}
// Token: 0x04000990 RID: 2448
private readonly Dictionary<string, object> _members;
}
}
@@ -0,0 +1,334 @@
using System;
using System.CodeDom.Compiler;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Reflection;
using SimpleJson.Reflection;
namespace SimpleJson
{
// Token: 0x020002E5 RID: 741
[GeneratedCode("simple-json", "1.0.0")]
internal class PocoJsonSerializerStrategy : IJsonSerializerStrategy
{
// Token: 0x060030AF RID: 12463 RVA: 0x00048130 File Offset: 0x00046330
public PocoJsonSerializerStrategy()
{
this.ConstructorCache = new ReflectionUtils.ThreadSafeDictionary<Type, ReflectionUtils.ConstructorDelegate>(new ReflectionUtils.ThreadSafeDictionaryValueFactory<Type, ReflectionUtils.ConstructorDelegate>(this.ContructorDelegateFactory));
this.GetCache = new ReflectionUtils.ThreadSafeDictionary<Type, IDictionary<string, ReflectionUtils.GetDelegate>>(new ReflectionUtils.ThreadSafeDictionaryValueFactory<Type, IDictionary<string, ReflectionUtils.GetDelegate>>(this.GetterValueFactory));
this.SetCache = new ReflectionUtils.ThreadSafeDictionary<Type, IDictionary<string, KeyValuePair<Type, ReflectionUtils.SetDelegate>>>(new ReflectionUtils.ThreadSafeDictionaryValueFactory<Type, IDictionary<string, KeyValuePair<Type, ReflectionUtils.SetDelegate>>>(this.SetterValueFactory));
}
// Token: 0x060030B0 RID: 12464 RVA: 0x0004818C File Offset: 0x0004638C
protected virtual string MapClrMemberNameToJsonFieldName(string clrPropertyName)
{
return clrPropertyName;
}
// Token: 0x060030B1 RID: 12465 RVA: 0x000481A4 File Offset: 0x000463A4
internal virtual ReflectionUtils.ConstructorDelegate ContructorDelegateFactory(Type key)
{
return ReflectionUtils.GetContructor(key, (!key.IsArray) ? PocoJsonSerializerStrategy.EmptyTypes : PocoJsonSerializerStrategy.ArrayConstructorParameterTypes);
}
// Token: 0x060030B2 RID: 12466 RVA: 0x000481DC File Offset: 0x000463DC
internal virtual IDictionary<string, ReflectionUtils.GetDelegate> GetterValueFactory(Type type)
{
IDictionary<string, ReflectionUtils.GetDelegate> dictionary = new Dictionary<string, ReflectionUtils.GetDelegate>();
foreach (PropertyInfo propertyInfo in ReflectionUtils.GetProperties(type))
{
if (propertyInfo.CanRead)
{
MethodInfo getterMethodInfo = ReflectionUtils.GetGetterMethodInfo(propertyInfo);
if (!getterMethodInfo.IsStatic && getterMethodInfo.IsPublic)
{
dictionary[this.MapClrMemberNameToJsonFieldName(propertyInfo.Name)] = ReflectionUtils.GetGetMethod(propertyInfo);
}
}
}
foreach (FieldInfo fieldInfo in ReflectionUtils.GetFields(type))
{
if (!fieldInfo.IsStatic && fieldInfo.IsPublic)
{
dictionary[this.MapClrMemberNameToJsonFieldName(fieldInfo.Name)] = ReflectionUtils.GetGetMethod(fieldInfo);
}
}
return dictionary;
}
// Token: 0x060030B3 RID: 12467 RVA: 0x0004830C File Offset: 0x0004650C
internal virtual IDictionary<string, KeyValuePair<Type, ReflectionUtils.SetDelegate>> SetterValueFactory(Type type)
{
IDictionary<string, KeyValuePair<Type, ReflectionUtils.SetDelegate>> dictionary = new Dictionary<string, KeyValuePair<Type, ReflectionUtils.SetDelegate>>();
foreach (PropertyInfo propertyInfo in ReflectionUtils.GetProperties(type))
{
if (propertyInfo.CanWrite)
{
MethodInfo setterMethodInfo = ReflectionUtils.GetSetterMethodInfo(propertyInfo);
if (!setterMethodInfo.IsStatic && setterMethodInfo.IsPublic)
{
dictionary[this.MapClrMemberNameToJsonFieldName(propertyInfo.Name)] = new KeyValuePair<Type, ReflectionUtils.SetDelegate>(propertyInfo.PropertyType, ReflectionUtils.GetSetMethod(propertyInfo));
}
}
}
foreach (FieldInfo fieldInfo in ReflectionUtils.GetFields(type))
{
if (!fieldInfo.IsInitOnly && !fieldInfo.IsStatic && fieldInfo.IsPublic)
{
dictionary[this.MapClrMemberNameToJsonFieldName(fieldInfo.Name)] = new KeyValuePair<Type, ReflectionUtils.SetDelegate>(fieldInfo.FieldType, ReflectionUtils.GetSetMethod(fieldInfo));
}
}
return dictionary;
}
// Token: 0x060030B4 RID: 12468 RVA: 0x00048460 File Offset: 0x00046660
public virtual bool TrySerializeNonPrimitiveObject(object input, out object output)
{
return this.TrySerializeKnownTypes(input, out output) || this.TrySerializeUnknownTypes(input, out output);
}
// Token: 0x060030B5 RID: 12469 RVA: 0x00048490 File Offset: 0x00046690
public virtual object DeserializeObject(object value, Type type)
{
if (type == null)
{
throw new ArgumentNullException("type");
}
string text = value as string;
object obj;
if (type == typeof(Guid) && string.IsNullOrEmpty(text))
{
obj = default(Guid);
}
else if (value == null)
{
obj = null;
}
else
{
object obj2 = null;
if (text != null)
{
if (text.Length != 0)
{
if (type == typeof(DateTime) || (ReflectionUtils.IsNullableType(type) && Nullable.GetUnderlyingType(type) == typeof(DateTime)))
{
return DateTime.ParseExact(text, PocoJsonSerializerStrategy.Iso8601Format, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal | DateTimeStyles.AssumeUniversal);
}
if (type == typeof(DateTimeOffset) || (ReflectionUtils.IsNullableType(type) && Nullable.GetUnderlyingType(type) == typeof(DateTimeOffset)))
{
return DateTimeOffset.ParseExact(text, PocoJsonSerializerStrategy.Iso8601Format, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal | DateTimeStyles.AssumeUniversal);
}
if (type == typeof(Guid) || (ReflectionUtils.IsNullableType(type) && Nullable.GetUnderlyingType(type) == typeof(Guid)))
{
return new Guid(text);
}
return text;
}
else
{
if (type == typeof(Guid))
{
obj2 = default(Guid);
}
else if (ReflectionUtils.IsNullableType(type) && Nullable.GetUnderlyingType(type) == typeof(Guid))
{
obj2 = null;
}
else
{
obj2 = text;
}
if (!ReflectionUtils.IsNullableType(type) && Nullable.GetUnderlyingType(type) == typeof(Guid))
{
return text;
}
}
}
else if (value is bool)
{
return value;
}
bool flag = value is long;
bool flag2 = value is double;
if ((flag && type == typeof(long)) || (flag2 && type == typeof(double)))
{
obj = value;
}
else if ((flag2 && type != typeof(double)) || (flag && type != typeof(long)))
{
obj2 = ((!typeof(IConvertible).IsAssignableFrom(type)) ? value : Convert.ChangeType(value, type, CultureInfo.InvariantCulture));
if (ReflectionUtils.IsNullableType(type))
{
obj = ReflectionUtils.ToNullableType(obj2, type);
}
else
{
obj = obj2;
}
}
else
{
IDictionary<string, object> dictionary = value as IDictionary<string, object>;
if (dictionary != null)
{
IDictionary<string, object> dictionary2 = dictionary;
if (ReflectionUtils.IsTypeDictionary(type))
{
Type[] genericTypeArguments = ReflectionUtils.GetGenericTypeArguments(type);
Type type2 = genericTypeArguments[0];
Type type3 = genericTypeArguments[1];
Type type4 = typeof(Dictionary<, >).MakeGenericType(new Type[] { type2, type3 });
IDictionary dictionary3 = (IDictionary)this.ConstructorCache[type4](null);
foreach (KeyValuePair<string, object> keyValuePair in dictionary2)
{
dictionary3.Add(keyValuePair.Key, this.DeserializeObject(keyValuePair.Value, type3));
}
obj2 = dictionary3;
}
else if (type == typeof(object))
{
obj2 = value;
}
else
{
obj2 = this.ConstructorCache[type](null);
foreach (KeyValuePair<string, KeyValuePair<Type, ReflectionUtils.SetDelegate>> keyValuePair2 in this.SetCache[type])
{
object obj3;
if (dictionary2.TryGetValue(keyValuePair2.Key, out obj3))
{
obj3 = this.DeserializeObject(obj3, keyValuePair2.Value.Key);
keyValuePair2.Value.Value(obj2, obj3);
}
}
}
}
else
{
IList<object> list = value as IList<object>;
if (list != null)
{
IList<object> list2 = list;
IList list3 = null;
if (type.IsArray)
{
list3 = (IList)this.ConstructorCache[type](new object[] { list2.Count });
int num = 0;
foreach (object obj4 in list2)
{
list3[num++] = this.DeserializeObject(obj4, type.GetElementType());
}
}
else if (ReflectionUtils.IsTypeGenericeCollectionInterface(type) || ReflectionUtils.IsAssignableFrom(typeof(IList), type))
{
Type type5 = ReflectionUtils.GetGenericTypeArguments(type)[0];
Type type6 = typeof(List<>).MakeGenericType(new Type[] { type5 });
list3 = (IList)this.ConstructorCache[type6](new object[] { list2.Count });
foreach (object obj5 in list2)
{
list3.Add(this.DeserializeObject(obj5, type5));
}
}
obj2 = list3;
}
}
obj = obj2;
}
}
return obj;
}
// Token: 0x060030B6 RID: 12470 RVA: 0x00048A7C File Offset: 0x00046C7C
protected virtual object SerializeEnum(Enum p)
{
return Convert.ToDouble(p, CultureInfo.InvariantCulture);
}
// Token: 0x060030B7 RID: 12471 RVA: 0x00048AA4 File Offset: 0x00046CA4
protected virtual bool TrySerializeKnownTypes(object input, out object output)
{
bool flag = true;
if (input is DateTime)
{
output = ((DateTime)input).ToUniversalTime().ToString(PocoJsonSerializerStrategy.Iso8601Format[0], CultureInfo.InvariantCulture);
}
else if (input is DateTimeOffset)
{
output = ((DateTimeOffset)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
{
Enum @enum = input as Enum;
if (@enum != null)
{
output = this.SerializeEnum(@enum);
}
else
{
flag = false;
output = null;
}
}
return flag;
}
// Token: 0x060030B8 RID: 12472 RVA: 0x00048B8C File Offset: 0x00046D8C
protected virtual bool TrySerializeUnknownTypes(object input, out object output)
{
if (input == null)
{
throw new ArgumentNullException("input");
}
output = null;
Type type = input.GetType();
bool flag;
if (type.FullName == null)
{
flag = false;
}
else
{
IDictionary<string, object> dictionary = new JsonObject();
IDictionary<string, ReflectionUtils.GetDelegate> dictionary2 = this.GetCache[type];
foreach (KeyValuePair<string, ReflectionUtils.GetDelegate> keyValuePair in dictionary2)
{
if (keyValuePair.Value != null)
{
dictionary.Add(this.MapClrMemberNameToJsonFieldName(keyValuePair.Key), keyValuePair.Value(input));
}
}
output = dictionary;
flag = true;
}
return flag;
}
// Token: 0x040009A0 RID: 2464
internal IDictionary<Type, ReflectionUtils.ConstructorDelegate> ConstructorCache;
// Token: 0x040009A1 RID: 2465
internal IDictionary<Type, IDictionary<string, ReflectionUtils.GetDelegate>> GetCache;
// Token: 0x040009A2 RID: 2466
internal IDictionary<Type, IDictionary<string, KeyValuePair<Type, ReflectionUtils.SetDelegate>>> SetCache;
// Token: 0x040009A3 RID: 2467
internal static readonly Type[] EmptyTypes = new Type[0];
// Token: 0x040009A4 RID: 2468
internal static readonly Type[] ArrayConstructorParameterTypes = new Type[] { typeof(int) };
// Token: 0x040009A5 RID: 2469
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,454 @@
using System;
using System.CodeDom.Compiler;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Reflection;
namespace SimpleJson.Reflection
{
// Token: 0x020002E6 RID: 742
[GeneratedCode("reflection-utils", "1.0.0")]
internal class ReflectionUtils
{
// Token: 0x060030BB RID: 12475 RVA: 0x00048CB8 File Offset: 0x00046EB8
public static Attribute GetAttribute(MemberInfo info, Type type)
{
Attribute attribute;
if (info == null || type == null || !Attribute.IsDefined(info, type))
{
attribute = null;
}
else
{
attribute = Attribute.GetCustomAttribute(info, type);
}
return attribute;
}
// Token: 0x060030BC RID: 12476 RVA: 0x00048CF4 File Offset: 0x00046EF4
public static Attribute GetAttribute(Type objectType, Type attributeType)
{
Attribute attribute;
if (objectType == null || attributeType == null || !Attribute.IsDefined(objectType, attributeType))
{
attribute = null;
}
else
{
attribute = Attribute.GetCustomAttribute(objectType, attributeType);
}
return attribute;
}
// Token: 0x060030BD RID: 12477 RVA: 0x00048D30 File Offset: 0x00046F30
public static Type[] GetGenericTypeArguments(Type type)
{
return type.GetGenericArguments();
}
// Token: 0x060030BE RID: 12478 RVA: 0x00048D4C File Offset: 0x00046F4C
public static bool IsTypeGenericeCollectionInterface(Type type)
{
bool flag;
if (!type.IsGenericType)
{
flag = false;
}
else
{
Type genericTypeDefinition = type.GetGenericTypeDefinition();
flag = genericTypeDefinition == typeof(IList<>) || genericTypeDefinition == typeof(ICollection<>) || genericTypeDefinition == typeof(IEnumerable<>);
}
return flag;
}
// Token: 0x060030BF RID: 12479 RVA: 0x00048DAC File Offset: 0x00046FAC
public static bool IsAssignableFrom(Type type1, Type type2)
{
return type1.IsAssignableFrom(type2);
}
// Token: 0x060030C0 RID: 12480 RVA: 0x00048DC8 File Offset: 0x00046FC8
public static bool IsTypeDictionary(Type type)
{
bool flag;
if (typeof(IDictionary).IsAssignableFrom(type))
{
flag = true;
}
else if (!type.IsGenericType)
{
flag = false;
}
else
{
Type genericTypeDefinition = type.GetGenericTypeDefinition();
flag = genericTypeDefinition == typeof(IDictionary<, >);
}
return flag;
}
// Token: 0x060030C1 RID: 12481 RVA: 0x00048E20 File Offset: 0x00047020
public static bool IsNullableType(Type type)
{
return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>);
}
// Token: 0x060030C2 RID: 12482 RVA: 0x00048E58 File Offset: 0x00047058
public static object ToNullableType(object obj, Type nullableType)
{
return (obj != null) ? Convert.ChangeType(obj, Nullable.GetUnderlyingType(nullableType), CultureInfo.InvariantCulture) : null;
}
// Token: 0x060030C3 RID: 12483 RVA: 0x00048E8C File Offset: 0x0004708C
public static bool IsValueType(Type type)
{
return type.IsValueType;
}
// Token: 0x060030C4 RID: 12484 RVA: 0x00048EA8 File Offset: 0x000470A8
public static IEnumerable<ConstructorInfo> GetConstructors(Type type)
{
return type.GetConstructors();
}
// Token: 0x060030C5 RID: 12485 RVA: 0x00048EC4 File Offset: 0x000470C4
public static ConstructorInfo GetConstructorInfo(Type type, params Type[] argsType)
{
IEnumerable<ConstructorInfo> constructors = ReflectionUtils.GetConstructors(type);
foreach (ConstructorInfo constructorInfo in constructors)
{
ParameterInfo[] parameters = constructorInfo.GetParameters();
if (argsType.Length == parameters.Length)
{
int num = 0;
bool flag = true;
foreach (ParameterInfo parameterInfo in constructorInfo.GetParameters())
{
if (parameterInfo.ParameterType != argsType[num])
{
flag = false;
break;
}
}
if (flag)
{
return constructorInfo;
}
}
}
return null;
}
// Token: 0x060030C6 RID: 12486 RVA: 0x00048F98 File Offset: 0x00047198
public static IEnumerable<PropertyInfo> GetProperties(Type type)
{
return type.GetProperties(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
}
// Token: 0x060030C7 RID: 12487 RVA: 0x00048FB8 File Offset: 0x000471B8
public static IEnumerable<FieldInfo> GetFields(Type type)
{
return type.GetFields(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
}
// Token: 0x060030C8 RID: 12488 RVA: 0x00048FD8 File Offset: 0x000471D8
public static MethodInfo GetGetterMethodInfo(PropertyInfo propertyInfo)
{
return propertyInfo.GetGetMethod(true);
}
// Token: 0x060030C9 RID: 12489 RVA: 0x00048FF4 File Offset: 0x000471F4
public static MethodInfo GetSetterMethodInfo(PropertyInfo propertyInfo)
{
return propertyInfo.GetSetMethod(true);
}
// Token: 0x060030CA RID: 12490 RVA: 0x00049010 File Offset: 0x00047210
public static ReflectionUtils.ConstructorDelegate GetContructor(ConstructorInfo constructorInfo)
{
return ReflectionUtils.GetConstructorByReflection(constructorInfo);
}
// Token: 0x060030CB RID: 12491 RVA: 0x0004902C File Offset: 0x0004722C
public static ReflectionUtils.ConstructorDelegate GetContructor(Type type, params Type[] argsType)
{
return ReflectionUtils.GetConstructorByReflection(type, argsType);
}
// Token: 0x060030CC RID: 12492 RVA: 0x00049048 File Offset: 0x00047248
public static ReflectionUtils.ConstructorDelegate GetConstructorByReflection(ConstructorInfo constructorInfo)
{
return (object[] args) => constructorInfo.Invoke(args);
}
// Token: 0x060030CD RID: 12493 RVA: 0x00049078 File Offset: 0x00047278
public static ReflectionUtils.ConstructorDelegate GetConstructorByReflection(Type type, params Type[] argsType)
{
ConstructorInfo constructorInfo = ReflectionUtils.GetConstructorInfo(type, argsType);
return (constructorInfo != null) ? ReflectionUtils.GetConstructorByReflection(constructorInfo) : null;
}
// Token: 0x060030CE RID: 12494 RVA: 0x000490A8 File Offset: 0x000472A8
public static ReflectionUtils.GetDelegate GetGetMethod(PropertyInfo propertyInfo)
{
return ReflectionUtils.GetGetMethodByReflection(propertyInfo);
}
// Token: 0x060030CF RID: 12495 RVA: 0x000490C4 File Offset: 0x000472C4
public static ReflectionUtils.GetDelegate GetGetMethod(FieldInfo fieldInfo)
{
return ReflectionUtils.GetGetMethodByReflection(fieldInfo);
}
// Token: 0x060030D0 RID: 12496 RVA: 0x000490E0 File Offset: 0x000472E0
public static ReflectionUtils.GetDelegate GetGetMethodByReflection(PropertyInfo propertyInfo)
{
MethodInfo methodInfo = ReflectionUtils.GetGetterMethodInfo(propertyInfo);
return (object source) => methodInfo.Invoke(source, ReflectionUtils.EmptyObjects);
}
// Token: 0x060030D1 RID: 12497 RVA: 0x00049114 File Offset: 0x00047314
public static ReflectionUtils.GetDelegate GetGetMethodByReflection(FieldInfo fieldInfo)
{
return (object source) => fieldInfo.GetValue(source);
}
// Token: 0x060030D2 RID: 12498 RVA: 0x00049144 File Offset: 0x00047344
public static ReflectionUtils.SetDelegate GetSetMethod(PropertyInfo propertyInfo)
{
return ReflectionUtils.GetSetMethodByReflection(propertyInfo);
}
// Token: 0x060030D3 RID: 12499 RVA: 0x00049160 File Offset: 0x00047360
public static ReflectionUtils.SetDelegate GetSetMethod(FieldInfo fieldInfo)
{
return ReflectionUtils.GetSetMethodByReflection(fieldInfo);
}
// Token: 0x060030D4 RID: 12500 RVA: 0x0004917C File Offset: 0x0004737C
public static ReflectionUtils.SetDelegate GetSetMethodByReflection(PropertyInfo propertyInfo)
{
MethodInfo methodInfo = ReflectionUtils.GetSetterMethodInfo(propertyInfo);
return delegate(object source, object value)
{
methodInfo.Invoke(source, new object[] { value });
};
}
// Token: 0x060030D5 RID: 12501 RVA: 0x000491B0 File Offset: 0x000473B0
public static ReflectionUtils.SetDelegate GetSetMethodByReflection(FieldInfo fieldInfo)
{
return delegate(object source, object value)
{
fieldInfo.SetValue(source, value);
};
}
// Token: 0x040009A6 RID: 2470
private static readonly object[] EmptyObjects = new object[0];
// Token: 0x020002E7 RID: 743
// (Invoke) Token: 0x060030D8 RID: 12504
public delegate object GetDelegate(object source);
// Token: 0x020002E8 RID: 744
// (Invoke) Token: 0x060030DC RID: 12508
public delegate void SetDelegate(object source, object value);
// Token: 0x020002E9 RID: 745
// (Invoke) Token: 0x060030E0 RID: 12512
public delegate object ConstructorDelegate(params object[] args);
// Token: 0x020002EA RID: 746
// (Invoke) Token: 0x060030E4 RID: 12516
public delegate TValue ThreadSafeDictionaryValueFactory<TKey, TValue>(TKey key);
// Token: 0x020002EB RID: 747
public sealed class ThreadSafeDictionary<TKey, TValue> : IDictionary<TKey, TValue>, ICollection<KeyValuePair<TKey, TValue>>, IEnumerable<KeyValuePair<TKey, TValue>>, IEnumerable
{
// Token: 0x060030E7 RID: 12519 RVA: 0x000491F0 File Offset: 0x000473F0
public ThreadSafeDictionary(ReflectionUtils.ThreadSafeDictionaryValueFactory<TKey, TValue> valueFactory)
{
this._valueFactory = valueFactory;
}
// Token: 0x060030E8 RID: 12520 RVA: 0x0004920C File Offset: 0x0004740C
private TValue Get(TKey key)
{
TValue tvalue;
TValue tvalue2;
if (this._dictionary == null)
{
tvalue = this.AddValue(key);
}
else if (!this._dictionary.TryGetValue(key, out tvalue2))
{
tvalue = this.AddValue(key);
}
else
{
tvalue = tvalue2;
}
return tvalue;
}
// Token: 0x060030E9 RID: 12521 RVA: 0x0004925C File Offset: 0x0004745C
private TValue AddValue(TKey key)
{
TValue tvalue = this._valueFactory(key);
object @lock = this._lock;
lock (@lock)
{
if (this._dictionary == null)
{
this._dictionary = new Dictionary<TKey, TValue>();
this._dictionary[key] = tvalue;
}
else
{
TValue tvalue2;
if (this._dictionary.TryGetValue(key, out tvalue2))
{
return tvalue2;
}
Dictionary<TKey, TValue> dictionary = new Dictionary<TKey, TValue>(this._dictionary);
dictionary[key] = tvalue;
this._dictionary = dictionary;
}
}
return tvalue;
}
// Token: 0x060030EA RID: 12522 RVA: 0x00049310 File Offset: 0x00047510
public void Add(TKey key, TValue value)
{
throw new NotImplementedException();
}
// Token: 0x060030EB RID: 12523 RVA: 0x00049318 File Offset: 0x00047518
public bool ContainsKey(TKey key)
{
return this._dictionary.ContainsKey(key);
}
// Token: 0x17000B07 RID: 2823
// (get) Token: 0x060030EC RID: 12524 RVA: 0x0004933C File Offset: 0x0004753C
public ICollection<TKey> Keys
{
get
{
return this._dictionary.Keys;
}
}
// Token: 0x060030ED RID: 12525 RVA: 0x0004935C File Offset: 0x0004755C
public bool Remove(TKey key)
{
throw new NotImplementedException();
}
// Token: 0x060030EE RID: 12526 RVA: 0x00049364 File Offset: 0x00047564
public bool TryGetValue(TKey key, out TValue value)
{
value = this[key];
return true;
}
// Token: 0x17000B08 RID: 2824
// (get) Token: 0x060030EF RID: 12527 RVA: 0x00049388 File Offset: 0x00047588
public ICollection<TValue> Values
{
get
{
return this._dictionary.Values;
}
}
// Token: 0x17000B09 RID: 2825
public TValue this[TKey key]
{
get
{
return this.Get(key);
}
set
{
throw new NotImplementedException();
}
}
// Token: 0x060030F2 RID: 12530 RVA: 0x000493CC File Offset: 0x000475CC
public void Add(KeyValuePair<TKey, TValue> item)
{
throw new NotImplementedException();
}
// Token: 0x060030F3 RID: 12531 RVA: 0x000493D4 File Offset: 0x000475D4
public void Clear()
{
throw new NotImplementedException();
}
// Token: 0x060030F4 RID: 12532 RVA: 0x000493DC File Offset: 0x000475DC
public bool Contains(KeyValuePair<TKey, TValue> item)
{
throw new NotImplementedException();
}
// Token: 0x060030F5 RID: 12533 RVA: 0x000493E4 File Offset: 0x000475E4
public void CopyTo(KeyValuePair<TKey, TValue>[] array, int arrayIndex)
{
throw new NotImplementedException();
}
// Token: 0x17000B0A RID: 2826
// (get) Token: 0x060030F6 RID: 12534 RVA: 0x000493EC File Offset: 0x000475EC
public int Count
{
get
{
return this._dictionary.Count;
}
}
// Token: 0x17000B0B RID: 2827
// (get) Token: 0x060030F7 RID: 12535 RVA: 0x0004940C File Offset: 0x0004760C
public bool IsReadOnly
{
get
{
throw new NotImplementedException();
}
}
// Token: 0x060030F8 RID: 12536 RVA: 0x00049414 File Offset: 0x00047614
public bool Remove(KeyValuePair<TKey, TValue> item)
{
throw new NotImplementedException();
}
// Token: 0x060030F9 RID: 12537 RVA: 0x0004941C File Offset: 0x0004761C
public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator()
{
return this._dictionary.GetEnumerator();
}
// Token: 0x060030FA RID: 12538 RVA: 0x00049444 File Offset: 0x00047644
IEnumerator IEnumerable.GetEnumerator()
{
return this._dictionary.GetEnumerator();
}
// Token: 0x040009A7 RID: 2471
private readonly object _lock = new object();
// Token: 0x040009A8 RID: 2472
private readonly ReflectionUtils.ThreadSafeDictionaryValueFactory<TKey, TValue> _valueFactory;
// Token: 0x040009A9 RID: 2473
private Dictionary<TKey, TValue> _dictionary;
}
}
}
+852
View File
@@ -0,0 +1,852 @@
using System;
using System.CodeDom.Compiler;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.Runtime.Serialization;
using System.Text;
using SimpleJson.Reflection;
namespace SimpleJson
{
// Token: 0x020002E3 RID: 739
[GeneratedCode("simple-json", "1.0.0")]
internal static class SimpleJson
{
// Token: 0x06003091 RID: 12433 RVA: 0x00046F90 File Offset: 0x00045190
public static object DeserializeObject(string json)
{
object obj;
if (SimpleJson.TryDeserializeObject(json, out obj))
{
return obj;
}
throw new SerializationException("Invalid JSON string");
}
// Token: 0x06003092 RID: 12434 RVA: 0x00046FC0 File Offset: 0x000451C0
public static bool TryDeserializeObject(string json, out object obj)
{
bool flag = true;
if (json != null)
{
char[] array = json.ToCharArray();
int num = 0;
obj = SimpleJson.ParseValue(array, ref num, ref flag);
}
else
{
obj = null;
}
return flag;
}
// Token: 0x06003093 RID: 12435 RVA: 0x00047000 File Offset: 0x00045200
public static object DeserializeObject(string json, Type type, IJsonSerializerStrategy jsonSerializerStrategy)
{
object obj = SimpleJson.DeserializeObject(json);
return (type != null && (obj == null || !ReflectionUtils.IsAssignableFrom(obj.GetType(), type))) ? (jsonSerializerStrategy ?? SimpleJson.CurrentJsonSerializerStrategy).DeserializeObject(obj, type) : obj;
}
// Token: 0x06003094 RID: 12436 RVA: 0x00047054 File Offset: 0x00045254
public static object DeserializeObject(string json, Type type)
{
return SimpleJson.DeserializeObject(json, type, null);
}
// Token: 0x06003095 RID: 12437 RVA: 0x00047074 File Offset: 0x00045274
public static T DeserializeObject<T>(string json, IJsonSerializerStrategy jsonSerializerStrategy)
{
return (T)((object)SimpleJson.DeserializeObject(json, typeof(T), jsonSerializerStrategy));
}
// Token: 0x06003096 RID: 12438 RVA: 0x000470A0 File Offset: 0x000452A0
public static T DeserializeObject<T>(string json)
{
return (T)((object)SimpleJson.DeserializeObject(json, typeof(T), null));
}
// Token: 0x06003097 RID: 12439 RVA: 0x000470CC File Offset: 0x000452CC
public static string SerializeObject(object json, IJsonSerializerStrategy jsonSerializerStrategy)
{
StringBuilder stringBuilder = new StringBuilder(2000);
bool flag = SimpleJson.SerializeValue(jsonSerializerStrategy, json, stringBuilder);
return (!flag) ? null : stringBuilder.ToString();
}
// Token: 0x06003098 RID: 12440 RVA: 0x00047108 File Offset: 0x00045308
public static string SerializeObject(object json)
{
return SimpleJson.SerializeObject(json, SimpleJson.CurrentJsonSerializerStrategy);
}
// Token: 0x06003099 RID: 12441 RVA: 0x00047128 File Offset: 0x00045328
public static string EscapeToJavascriptString(string jsonString)
{
string text;
if (string.IsNullOrEmpty(jsonString))
{
text = jsonString;
}
else
{
StringBuilder stringBuilder = new StringBuilder();
int i = 0;
while (i < jsonString.Length)
{
char c = jsonString[i++];
if (c == '\\')
{
int num = jsonString.Length - i;
if (num >= 2)
{
char c2 = jsonString[i];
if (c2 == '\\')
{
stringBuilder.Append('\\');
i++;
}
else if (c2 == '"')
{
stringBuilder.Append("\"");
i++;
}
else if (c2 == 't')
{
stringBuilder.Append('\t');
i++;
}
else if (c2 == 'b')
{
stringBuilder.Append('\b');
i++;
}
else if (c2 == 'n')
{
stringBuilder.Append('\n');
i++;
}
else if (c2 == 'r')
{
stringBuilder.Append('\r');
i++;
}
}
}
else
{
stringBuilder.Append(c);
}
}
text = stringBuilder.ToString();
}
return text;
}
// Token: 0x0600309A RID: 12442 RVA: 0x00047260 File Offset: 0x00045460
private 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 text = 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 obj = SimpleJson.ParseValue(json, ref index, ref success);
if (!success)
{
success = false;
return null;
}
dictionary[text] = obj;
}
continue;
}
success = false;
return null;
}
return dictionary;
}
// Token: 0x0600309B RID: 12443 RVA: 0x00047338 File Offset: 0x00045538
private 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 obj = SimpleJson.ParseValue(json, ref index, ref success);
if (!success)
{
return null;
}
jsonArray.Add(obj);
}
continue;
}
success = false;
return null;
}
return jsonArray;
}
// Token: 0x0600309C RID: 12444 RVA: 0x000473D0 File Offset: 0x000455D0
private 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: 0x0600309D RID: 12445 RVA: 0x000474A4 File Offset: 0x000456A4
private 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 text;
if (!(success = uint.TryParse(new string(json, index, 4), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out num2)))
{
text = "";
}
else
{
if (55296U > num2 || num2 > 56319U)
{
stringBuilder.Append(SimpleJson.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;
text = "";
}
return text;
}
break;
}
}
else
{
stringBuilder.Append(c);
}
}
if (!flag)
{
success = false;
return null;
}
return stringBuilder.ToString();
}
// Token: 0x0600309E RID: 12446 RVA: 0x0004772C File Offset: 0x0004592C
private static string ConvertFromUtf32(int utf32)
{
if (utf32 < 0 || utf32 > 1114111)
{
throw new ArgumentOutOfRangeException("utf32", "The argument must be from 0 to 0x10FFFF.");
}
if (55296 <= utf32 && utf32 <= 57343)
{
throw new ArgumentOutOfRangeException("utf32", "The argument must not be in surrogate pair range.");
}
string text;
if (utf32 < 65536)
{
text = new string((char)utf32, 1);
}
else
{
utf32 -= 65536;
text = new string(new char[]
{
(char)((utf32 >> 10) + 55296),
(char)(utf32 % 1024 + 56320)
});
}
return text;
}
// Token: 0x0600309F RID: 12447 RVA: 0x000477D8 File Offset: 0x000459D8
private static object ParseNumber(char[] json, ref int index, ref bool success)
{
SimpleJson.EatWhitespace(json, ref index);
int lastIndexOfNumber = SimpleJson.GetLastIndexOfNumber(json, index);
int num = lastIndexOfNumber - index + 1;
string text = new string(json, index, num);
object obj;
if (text.IndexOf(".", StringComparison.OrdinalIgnoreCase) != -1 || text.IndexOf("e", StringComparison.OrdinalIgnoreCase) != -1)
{
double num2;
success = double.TryParse(new string(json, index, num), NumberStyles.Any, CultureInfo.InvariantCulture, out num2);
obj = num2;
}
else
{
long num3;
success = long.TryParse(new string(json, index, num), NumberStyles.Any, CultureInfo.InvariantCulture, out num3);
obj = num3;
}
index = lastIndexOfNumber + 1;
return obj;
}
// Token: 0x060030A0 RID: 12448 RVA: 0x0004788C File Offset: 0x00045A8C
private 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: 0x060030A1 RID: 12449 RVA: 0x000478D0 File Offset: 0x00045AD0
private 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: 0x060030A2 RID: 12450 RVA: 0x00047904 File Offset: 0x00045B04
private static int LookAhead(char[] json, int index)
{
int num = index;
return SimpleJson.NextToken(json, ref num);
}
// Token: 0x060030A3 RID: 12451 RVA: 0x00047924 File Offset: 0x00045B24
private static int NextToken(char[] json, ref int index)
{
SimpleJson.EatWhitespace(json, ref index);
int num;
if (index == json.Length)
{
num = 0;
}
else
{
char c = json[index];
index++;
switch (c)
{
case ',':
num = 6;
break;
case '-':
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
num = 8;
break;
default:
switch (c)
{
case '[':
num = 3;
break;
default:
switch (c)
{
case '{':
num = 1;
break;
default:
if (c != '"')
{
index--;
int num2 = json.Length - index;
if (num2 >= 5)
{
if (json[index] == 'f' && json[index + 1] == 'a' && json[index + 2] == 'l' && json[index + 3] == 's' && json[index + 4] == 'e')
{
index += 5;
num = 10;
break;
}
}
if (num2 >= 4)
{
if (json[index] == 't' && json[index + 1] == 'r' && json[index + 2] == 'u' && json[index + 3] == 'e')
{
index += 4;
num = 9;
break;
}
}
if (num2 >= 4)
{
if (json[index] == 'n' && json[index + 1] == 'u' && json[index + 2] == 'l' && json[index + 3] == 'l')
{
index += 4;
num = 11;
break;
}
}
num = 0;
}
else
{
num = 7;
}
break;
case '}':
num = 2;
break;
}
break;
case ']':
num = 4;
break;
}
break;
case ':':
num = 5;
break;
}
}
return num;
}
// Token: 0x060030A4 RID: 12452 RVA: 0x00047B0C File Offset: 0x00045D0C
private static bool SerializeValue(IJsonSerializerStrategy jsonSerializerStrategy, object value, StringBuilder builder)
{
bool flag = true;
string text = value as string;
if (text != null)
{
flag = SimpleJson.SerializeString(text, builder);
}
else
{
IDictionary<string, object> dictionary = value as IDictionary<string, object>;
if (dictionary != null)
{
flag = SimpleJson.SerializeObject(jsonSerializerStrategy, dictionary.Keys, dictionary.Values, builder);
}
else
{
IDictionary<string, string> dictionary2 = value as IDictionary<string, string>;
if (dictionary2 != null)
{
flag = SimpleJson.SerializeObject(jsonSerializerStrategy, dictionary2.Keys, dictionary2.Values, builder);
}
else
{
IEnumerable enumerable = value as IEnumerable;
if (enumerable != null)
{
flag = SimpleJson.SerializeArray(jsonSerializerStrategy, enumerable, 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 obj;
flag = jsonSerializerStrategy.TrySerializeNonPrimitiveObject(value, out obj);
if (flag)
{
SimpleJson.SerializeValue(jsonSerializerStrategy, obj, builder);
}
}
}
}
}
return flag;
}
// Token: 0x060030A5 RID: 12453 RVA: 0x00047C30 File Offset: 0x00045E30
private 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 obj2 = enumerator2.Current;
if (!flag)
{
builder.Append(",");
}
string text = obj as string;
if (text != null)
{
SimpleJson.SerializeString(text, builder);
}
else if (!SimpleJson.SerializeValue(jsonSerializerStrategy, obj2, builder))
{
return false;
}
builder.Append(":");
if (SimpleJson.SerializeValue(jsonSerializerStrategy, obj2, builder))
{
flag = false;
continue;
}
return false;
}
builder.Append("}");
return true;
}
// Token: 0x060030A6 RID: 12454 RVA: 0x00047D08 File Offset: 0x00045F08
private static bool SerializeArray(IJsonSerializerStrategy jsonSerializerStrategy, IEnumerable anArray, StringBuilder builder)
{
builder.Append("[");
bool flag = true;
IEnumerator enumerator = anArray.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
object obj = enumerator.Current;
if (!flag)
{
builder.Append(",");
}
if (!SimpleJson.SerializeValue(jsonSerializerStrategy, obj, builder))
{
return false;
}
flag = false;
}
}
finally
{
IDisposable disposable;
if ((disposable = enumerator as IDisposable) != null)
{
disposable.Dispose();
}
}
builder.Append("]");
return true;
}
// Token: 0x060030A7 RID: 12455 RVA: 0x00047DAC File Offset: 0x00045FAC
private 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: 0x060030A8 RID: 12456 RVA: 0x00047EB4 File Offset: 0x000460B4
private 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: 0x060030A9 RID: 12457 RVA: 0x00047FF0 File Offset: 0x000461F0
private 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: 0x17000B05 RID: 2821
// (get) Token: 0x060030AA RID: 12458 RVA: 0x000480CC File Offset: 0x000462CC
// (set) Token: 0x060030AB RID: 12459 RVA: 0x000480F8 File Offset: 0x000462F8
public static IJsonSerializerStrategy CurrentJsonSerializerStrategy
{
get
{
IJsonSerializerStrategy jsonSerializerStrategy;
if ((jsonSerializerStrategy = SimpleJson._currentJsonSerializerStrategy) == null)
{
jsonSerializerStrategy = (SimpleJson._currentJsonSerializerStrategy = SimpleJson.PocoJsonSerializerStrategy);
}
return jsonSerializerStrategy;
}
set
{
SimpleJson._currentJsonSerializerStrategy = value;
}
}
// Token: 0x17000B06 RID: 2822
// (get) Token: 0x060030AC RID: 12460 RVA: 0x00048104 File Offset: 0x00046304
[EditorBrowsable(EditorBrowsableState.Advanced)]
public static PocoJsonSerializerStrategy PocoJsonSerializerStrategy
{
get
{
PocoJsonSerializerStrategy pocoJsonSerializerStrategy;
if ((pocoJsonSerializerStrategy = SimpleJson._pocoJsonSerializerStrategy) == null)
{
pocoJsonSerializerStrategy = (SimpleJson._pocoJsonSerializerStrategy = new PocoJsonSerializerStrategy());
}
return pocoJsonSerializerStrategy;
}
}
// Token: 0x04000991 RID: 2449
private const int TOKEN_NONE = 0;
// Token: 0x04000992 RID: 2450
private const int TOKEN_CURLY_OPEN = 1;
// Token: 0x04000993 RID: 2451
private const int TOKEN_CURLY_CLOSE = 2;
// Token: 0x04000994 RID: 2452
private const int TOKEN_SQUARED_OPEN = 3;
// Token: 0x04000995 RID: 2453
private const int TOKEN_SQUARED_CLOSE = 4;
// Token: 0x04000996 RID: 2454
private const int TOKEN_COLON = 5;
// Token: 0x04000997 RID: 2455
private const int TOKEN_COMMA = 6;
// Token: 0x04000998 RID: 2456
private const int TOKEN_STRING = 7;
// Token: 0x04000999 RID: 2457
private const int TOKEN_NUMBER = 8;
// Token: 0x0400099A RID: 2458
private const int TOKEN_TRUE = 9;
// Token: 0x0400099B RID: 2459
private const int TOKEN_FALSE = 10;
// Token: 0x0400099C RID: 2460
private const int TOKEN_NULL = 11;
// Token: 0x0400099D RID: 2461
private const int BUILDER_CAPACITY = 2000;
// Token: 0x0400099E RID: 2462
private static IJsonSerializerStrategy _currentJsonSerializerStrategy;
// Token: 0x0400099F RID: 2463
private static PocoJsonSerializerStrategy _pocoJsonSerializerStrategy;
}
}