コード例 #1
0
        public DescribeRaidArraysResult Unmarshall(JsonUnmarshallerContext context)
        {
            if (context.CurrentTokenType == JsonUnmarshallerContext.TokenType.Null)
            {
                return(null);
            }
            DescribeRaidArraysResult describeRaidArraysResult = new DescribeRaidArraysResult();

            describeRaidArraysResult.RaidArrays = null;

            int originalDepth = context.CurrentDepth;
            int targetDepth   = originalDepth + 1;

            while (context.Read())
            {
                if ((context.IsKey) && (context.CurrentDepth == targetDepth))
                {
                    context.Read();
                    context.Read();

                    if (context.TestExpression("RaidArrays", targetDepth))
                    {
                        describeRaidArraysResult.RaidArrays = new List <RaidArray>();
                        RaidArrayUnmarshaller unmarshaller = RaidArrayUnmarshaller.GetInstance();
                        while (context.Read())
                        {
                            if ((context.IsArrayElement) && (context.CurrentDepth == targetDepth))
                            {
                                describeRaidArraysResult.RaidArrays.Add(unmarshaller.Unmarshall(context));
                            }
                            else if (context.IsEndArray)
                            {
                                break;
                            }
                        }
                        continue;
                    }
                }
                else if (context.IsEndElement && context.CurrentDepth <= originalDepth)
                {
                    return(describeRaidArraysResult);
                }
            }


            return(describeRaidArraysResult);
        }
コード例 #2
0
        private static void UnmarshallResult(JsonUnmarshallerContext context, DescribeRaidArraysResponse response)
        {
            int originalDepth = context.CurrentDepth;
            int targetDepth   = originalDepth + 1;

            while (context.Read())
            {
                if (context.TestExpression("RaidArrays", targetDepth))
                {
                    context.Read();
                    response.RaidArrays = new List <RaidArray>();
                    RaidArrayUnmarshaller unmarshaller = RaidArrayUnmarshaller.GetInstance();
                    while (context.Read())
                    {
                        JsonToken token = context.CurrentTokenType;
                        if (token == JsonToken.ArrayStart)
                        {
                            continue;
                        }
                        if (token == JsonToken.ArrayEnd)
                        {
                            break;
                        }
                        response.RaidArrays.Add(unmarshaller.Unmarshall(context));
                    }
                    continue;
                }

                if (context.CurrentDepth <= originalDepth)
                {
                    return;
                }
            }

            return;
        }