コード例 #1
0
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            TestRoleResponse response = new TestRoleResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("Success", targetDepth))
                {
                    response.Success = StringUnmarshaller.GetInstance().Unmarshall(context);
                    continue;
                }

                if (context.TestExpression("Messages", targetDepth))
                {
                    var unmarshaller = new ListUnmarshaller <String, StringUnmarshaller>(
                        StringUnmarshaller.GetInstance());
                    response.Messages = unmarshaller.Unmarshall(context);

                    continue;
                }
            }

            return(response);
        }
コード例 #2
0
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            TestRoleResponse response = new TestRoleResponse();

            context.Read();

            UnmarshallResult(context, response);
            return(response);
        }
コード例 #3
0
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            TestRoleResponse response = new TestRoleResponse();

            context.Read();

            response.TestRoleResult = TestRoleResultUnmarshaller.GetInstance().Unmarshall(context);

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

            while (context.Read())
            {
                if (context.TestExpression("Success", targetDepth))
                {
                    context.Read();
                    response.Success = StringUnmarshaller.GetInstance().Unmarshall(context);
                    continue;
                }

                if (context.TestExpression("Messages", targetDepth))
                {
                    context.Read();

                    if (context.CurrentTokenType == JsonToken.Null)
                    {
                        response.Messages = null;
                        continue;
                    }
                    response.Messages = new List <String>();
                    StringUnmarshaller unmarshaller = StringUnmarshaller.GetInstance();
                    while (context.Read())
                    {
                        JsonToken token = context.CurrentTokenType;
                        if (token == JsonToken.ArrayStart)
                        {
                            continue;
                        }
                        if (token == JsonToken.ArrayEnd)
                        {
                            break;
                        }
                        response.Messages.Add(unmarshaller.Unmarshall(context));
                    }
                    continue;
                }

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

            return;
        }