Exemplo n.º 1
0
        private static SimpleObject[][] ReadNestedArrayOfSimpleObjects(
            IObjectReader reader)
        {
            SimpleObject[][] array = null;

            if (reader.ReadStartArray())
            {
                List<SimpleObject[]> list = new List<SimpleObject[]>();

                while (reader.MoveToNextArrayValue())
                {
                    if (reader.ReadStartArray())
                    {
                        List<SimpleObject> innerList = new List<SimpleObject>();

                        while (reader.MoveToNextArrayValue())
                        {
                            SimpleObject innerObject = SimpleObject.ReadFrom(reader);
                            innerList.Add(innerObject);
                        }

                        reader.ReadEndArray();

                        list.Add(innerList.ToArray());
                    }
                    else
                    {
                        list.Add(null);
                    }
                }

                reader.ReadEndArray();

                array = list.ToArray();
            }

            return array;
        }
Exemplo n.º 2
0
        private static string[][] ReadNestedArrayOfStrings(
            IObjectReader reader)
        {
            string[][] array = null;

            if (reader.ReadStartArray())
            {
                List<string[]> list = new List<string[]>();

                while (reader.MoveToNextArrayValue())
                {
                    if (reader.ReadStartArray())
                    {
                        List<string> innerList = new List<string>();

                        while (reader.MoveToNextArrayValue())
                        {
                            innerList.Add(reader.ReadValueAsString(MaximumValueLengthInBytes));
                        }

                        reader.ReadEndArray();

                        list.Add(innerList.ToArray());
                    }
                    else
                    {
                        list.Add(null);
                    }
                }

                reader.ReadEndArray();

                array = list.ToArray();
            }

            return array;
        }
Exemplo n.º 3
0
        private static SimpleObject[] ReadArrayOfSimpleObjects(
            IObjectReader reader)
        {
            SimpleObject[] array = null;

            if (reader.ReadStartArray())
            {
                List<SimpleObject> list = new List<SimpleObject>();

                while (reader.MoveToNextArrayValue())
                {
                    list.Add(SimpleObject.ReadFrom(reader));
                }

                reader.ReadEndArray();

                array = list.ToArray();
            }

            return array;
        }
Exemplo n.º 4
0
        private static int[][] ReadNestedArrayOfInts(
            IObjectReader reader)
        {
            int[][] array = null;

            if (reader.ReadStartArray())
            {
                List<int[]> list = new List<int[]>();

                while (reader.MoveToNextArrayValue())
                {
                    if (reader.ReadStartArray())
                    {
                        List<int> innerList = new List<int>();

                        while (reader.MoveToNextArrayValue())
                        {
                            innerList.Add(reader.ReadValueAsInt32());
                        }

                        reader.ReadEndArray();

                        list.Add(innerList.ToArray());
                    }
                    else
                    {
                        list.Add(null);
                    }
                }

                reader.ReadEndArray();

                array = list.ToArray();
            }

            return array;
        }
            public static JsonNetSimpleObject ReadFrom(
                IObjectReader reader)
            {
                JsonNetSimpleObject obj = null;

                if (reader.ReadStartObject())
                {
                    obj = new JsonNetSimpleObject();

                    int memberKey;

                    while (reader.ReadNextMemberKey())
                    {
                        memberKey = reader.MemberKey;

                        if (memberKey == 1)
                        {
                            obj.Id = reader.ReadValueAsInt32();
                        }
                        else if (memberKey == 2)
                        {
                            obj.Name = reader.ReadValueAsString(StringQuotaInBytes);
                        }
                        else if (memberKey == 3)
                        {
                            obj.Address = reader.ReadValueAsString(StringQuotaInBytes);
                        }
                        else if (memberKey == 4)
                        {
                            obj.Scores = null;

                            if (reader.ReadStartArray())
                            {
                                List<int> list = new List<int>();

                                while (reader.MoveToNextArrayValue())
                                {
                                    list.Add(reader.ReadValueAsInt32());
                                }

                                reader.ReadEndArray();

                                obj.Scores = list.ToArray();
                            }
                        }
                    }

                    reader.ReadEndObject();
                }

                return obj;
            }