private static object parseObjectArray(JSONParser.Context ctx, JSONParser.ParseElement <object> parser, Type type) { JSONParser.forward(ctx); if ((int)ctx.src[ctx.pos] != 91) { throw new JSONParser.InvalidCharacterException(ctx); } ++ctx.pos; int count = ctx.ab.Count; while (true) { JSONParser.forward(ctx); ctx.ab.Add(parser(ctx, type)); JSONParser.forward(ctx); if ((int)ctx.src[ctx.pos] == 44) { ++ctx.pos; } else { break; } } if ((int)ctx.src[ctx.pos] != 93) { throw new JSONParser.UnexpectedCharacterException(ctx); } ++ctx.pos; Array array = (Array)null; if ((object)type != null) { array = Array.CreateInstance(type, ctx.ab.Count - count); for (int index = 0; index < array.Length; ++index) { array.SetValue(ctx.ab[index + count], index); } } ctx.ab.RemoveRange(count, ctx.ab.Count - count); return((object)array); }
private static object parseValueArray <T>(JSONParser.Context ctx, JSONParser.ParseElement <T> parser) { JSONParser.forward(ctx); if ((int)ctx.src[ctx.pos] != 91) { throw new JSONParser.InvalidCharacterException(ctx); } ++ctx.pos; Type type = typeof(T); int count = ctx.ab.Count; while (true) { JSONParser.forward(ctx); ctx.ab.Add((object)parser(ctx, type)); JSONParser.forward(ctx); if ((int)ctx.src[ctx.pos] == 44) { ++ctx.pos; } else { break; } } if ((int)ctx.src[ctx.pos] != 93) { throw new JSONParser.UnexpectedCharacterException(ctx); } ++ctx.pos; T[] objArray = new T[ctx.ab.Count - count]; for (int index = 0; index < objArray.Length; ++index) { objArray[index] = (T)ctx.ab[index + count]; } ctx.ab.RemoveRange(count, ctx.ab.Count - count); return((object)objArray); }