public static object DeserializeList(string data, Type t) { IList list = (IList)Activator.CreateInstance(t); if (((data != null) ? data.Length : 0) != 0) { t = t.GetGenericArguments()[0]; using (StringReader stringReader = new StringReader(data)) { int num = BloxStringSerializer.ReadIntFromStringReader(stringReader); if (num > 0) { for (int i = 0; i < num; i++) { int num2 = BloxStringSerializer.ReadIntFromStringReader(stringReader); if (num2 == 0) { list.Add(BloxStringSerializer.Deserialize(null, t)); } else { char[] array = new char[num2]; stringReader.ReadBlock(array, 0, num2); object value = BloxStringSerializer.Deserialize(array.ToString(), t); list.Add(value); } } return(list); } return(list); } } return(list); }
public static object DeserializeArray(string data, Type t) { t = t.GetElementType(); if (((data != null) ? data.Length : 0) != 0) { Array array = null; using (StringReader stringReader = new StringReader(data)) { int num = BloxStringSerializer.ReadIntFromStringReader(stringReader); array = Array.CreateInstance(t, num); if (num > 0) { for (int i = 0; i < num; i++) { int num2 = BloxStringSerializer.ReadIntFromStringReader(stringReader); if (num2 == 0) { array.SetValue(BloxStringSerializer.Deserialize(null, t), i); } else { char[] array2 = new char[num2]; stringReader.ReadBlock(array2, 0, num2); object value = BloxStringSerializer.Deserialize(array2.ToString(), t); array.SetValue(value, i); } } return(array); } return(array); } } return(Array.CreateInstance(t, 0)); }