public static UserProfileUnmarshaller GetInstance()
 {
     if (instance == null)
     {
         instance = new UserProfileUnmarshaller();
     }
     return(instance);
 }
        public DescribeUserProfilesResult Unmarshall(JsonUnmarshallerContext context)
        {
            if (context.CurrentTokenType == JsonUnmarshallerContext.TokenType.Null)
            {
                return(null);
            }
            DescribeUserProfilesResult describeUserProfilesResult = new DescribeUserProfilesResult();

            describeUserProfilesResult.UserProfiles = 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("UserProfiles", targetDepth))
                    {
                        describeUserProfilesResult.UserProfiles = new List <UserProfile>();
                        UserProfileUnmarshaller unmarshaller = UserProfileUnmarshaller.GetInstance();
                        while (context.Read())
                        {
                            if ((context.IsArrayElement) && (context.CurrentDepth == targetDepth))
                            {
                                describeUserProfilesResult.UserProfiles.Add(unmarshaller.Unmarshall(context));
                            }
                            else if (context.IsEndArray)
                            {
                                break;
                            }
                        }
                        continue;
                    }
                }
                else if (context.IsEndElement && context.CurrentDepth <= originalDepth)
                {
                    return(describeUserProfilesResult);
                }
            }


            return(describeUserProfilesResult);
        }
Example #3
0
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            DescribeUserProfilesResponse response = new DescribeUserProfilesResponse();

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

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("UserProfiles", targetDepth))
                {
                    var unmarshaller = new ListUnmarshaller <UserProfile, UserProfileUnmarshaller>(
                        UserProfileUnmarshaller.GetInstance());
                    response.UserProfiles = unmarshaller.Unmarshall(context);

                    continue;
                }
            }

            return(response);
        }
Example #4
0
        private static void UnmarshallResult(JsonUnmarshallerContext context, DescribeUserProfilesResponse response)
        {
            int originalDepth = context.CurrentDepth;
            int targetDepth   = originalDepth + 1;

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

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

            return;
        }