private static bool GetTypeArray(JSON.Object o, Type type, string key, ref object value) { JSON.Array result = default(JSON.Array); if (!o.Get(key, ref result)) { return(false); } int count = result.Count; Array array = Array.CreateInstance(type, count); for (int i = 0; i < count; ++i) { JSON.Object tmp1 = default(JSON.Object); if (!o.Get(key, ref tmp1)) { return(false); } JSON.Readable tmp2; try { tmp2 = (JSON.Readable)Activator.CreateInstance(type); } catch (Exception) { return(false); } if (!tmp2.Read(tmp1)) { return(false); } array.SetValue(tmp2, i); } value = array; return(true); }
private static bool GetEnumArray(JSON.Object o, Type type, string key, ref object value) { JSON.Array result = default(JSON.Array); if (!o.Get(key, ref result)) { return(false); } int count = result.Count; Array array = Array.CreateInstance(type, count); for (int i = 0; i < count; ++i) { string tmp1 = default(string); if (!o.Get(key, ref tmp1)) { return(false); } object tmp2; try { tmp2 = Enum.Parse(type, tmp1); } catch (Exception) { return(false); } array.SetValue(tmp2, i); } value = array; return(true); }
private static bool GetEnumNullable(JSON.Object o, Type type, string key, ref object value) { string result = default(string); if (!o.Get(key, ref result)) { return(false); } if (string.IsNullOrEmpty(result)) { value = Activator.CreateInstance(typeof(Nullable <>).MakeGenericType(type)); return(true); } object tmp; try { tmp = Enum.Parse(type, result); } catch (Exception) { return(false); } value = Activator.CreateInstance(typeof(Nullable <>).MakeGenericType(type), tmp); return(true); }
private static bool GetTypeNullable(JSON.Object o, Type type, string key, ref object value) { JSON.Object result = default(JSON.Object); if (!o.Get(key, ref result)) { return(false); } if (result == null) { value = Activator.CreateInstance(typeof(Nullable <>).MakeGenericType(type)); return(true); } JSON.Readable tmp; try { tmp = (JSON.Readable)Activator.CreateInstance(type); } catch (Exception) { return(false); } if (!tmp.Read(result)) { return(false); } value = Activator.CreateInstance(typeof(Nullable <>).MakeGenericType(type), tmp); return(true); }
private static bool GetEnum(JSON.Object o, Type type, string key, ref object value) { string result = default(string); if (!o.Get(key, ref result)) { return(false); } try { value = Enum.Parse(type, result); } catch (Exception) { return(false); } return(true); }
private static bool GetType(JSON.Object o, Type type, string key, ref object value) { JSON.Object result = default(JSON.Object); if (!o.Get(key, ref result)) { return(false); } JSON.Readable tmp; try { tmp = (JSON.Readable)Activator.CreateInstance(type); } catch (Exception) { return(false); } if (!tmp.Read(result)) { return(false); } value = tmp; return(true); }
private static bool Get(JSON.Object o, string key, ref JSON.Array a) { return(o.Get(key, ref a)); }
private static bool Get(JSON.Object o, string key, ref JSON.Object oo) { return(o.Get(key, ref oo)); }
private static bool Get(JSON.Object o, string key, ref double d) { return(o.Get(key, ref d)); }
private static bool Get(JSON.Object o, string key, ref int i) { return(o.Get(key, ref i)); }