/// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context)
        {
            ListEntitiesForPolicyResponse response = new ListEntitiesForPolicyResponse();

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

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.IsStartElement)
                {
                    if (context.TestExpression("ListEntitiesForPolicyResult", 2))
                    {
                        UnmarshallResult(context, response);
                        continue;
                    }

                    if (context.TestExpression("ResponseMetadata", 2))
                    {
                        response.ResponseMetadata = ResponseMetadataUnmarshaller.Instance.Unmarshall(context);
                    }
                }
            }

            return(response);
        }
        private static void UnmarshallResult(XmlUnmarshallerContext context, ListEntitiesForPolicyResponse response)
        {
            int originalDepth = context.CurrentDepth;
            int targetDepth   = originalDepth + 1;

            if (context.IsStartOfDocument)
            {
                targetDepth += 2;
            }

            while (context.ReadAtDepth(originalDepth))
            {
                if (context.IsStartElement || context.IsAttribute)
                {
                    if (context.TestExpression("IsTruncated", targetDepth))
                    {
                        var unmarshaller = BoolUnmarshaller.Instance;
                        response.IsTruncated = unmarshaller.Unmarshall(context);
                        continue;
                    }
                    if (context.TestExpression("Marker", targetDepth))
                    {
                        var unmarshaller = StringUnmarshaller.Instance;
                        response.Marker = unmarshaller.Unmarshall(context);
                        continue;
                    }
                    if (context.TestExpression("PolicyGroups/member", targetDepth))
                    {
                        var unmarshaller = PolicyGroupUnmarshaller.Instance;
                        var item         = unmarshaller.Unmarshall(context);
                        response.PolicyGroups.Add(item);
                        continue;
                    }
                    if (context.TestExpression("PolicyRoles/member", targetDepth))
                    {
                        var unmarshaller = PolicyRoleUnmarshaller.Instance;
                        var item         = unmarshaller.Unmarshall(context);
                        response.PolicyRoles.Add(item);
                        continue;
                    }
                    if (context.TestExpression("PolicyUsers/member", targetDepth))
                    {
                        var unmarshaller = PolicyUserUnmarshaller.Instance;
                        var item         = unmarshaller.Unmarshall(context);
                        response.PolicyUsers.Add(item);
                        continue;
                    }
                }
            }

            return;
        }
コード例 #3
0
        public static ListEntitiesForPolicyResponse Unmarshall(UnmarshallerContext context)
        {
            ListEntitiesForPolicyResponse listEntitiesForPolicyResponse = new ListEntitiesForPolicyResponse();

            listEntitiesForPolicyResponse.HttpResponse = context.HttpResponse;
            listEntitiesForPolicyResponse.RequestId    = context.StringValue("ListEntitiesForPolicy.RequestId");

            List <ListEntitiesForPolicyResponse.ListEntitiesForPolicy_Group> listEntitiesForPolicyResponse_groups = new List <ListEntitiesForPolicyResponse.ListEntitiesForPolicy_Group>();

            for (int i = 0; i < context.Length("ListEntitiesForPolicy.Groups.Length"); i++)
            {
                ListEntitiesForPolicyResponse.ListEntitiesForPolicy_Group group = new ListEntitiesForPolicyResponse.ListEntitiesForPolicy_Group();
                group.GroupName  = context.StringValue("ListEntitiesForPolicy.Groups[" + i + "].GroupName");
                group.Comments   = context.StringValue("ListEntitiesForPolicy.Groups[" + i + "].Comments");
                group.AttachDate = context.StringValue("ListEntitiesForPolicy.Groups[" + i + "].AttachDate");

                listEntitiesForPolicyResponse_groups.Add(group);
            }
            listEntitiesForPolicyResponse.Groups = listEntitiesForPolicyResponse_groups;

            List <ListEntitiesForPolicyResponse.ListEntitiesForPolicy_User> listEntitiesForPolicyResponse_users = new List <ListEntitiesForPolicyResponse.ListEntitiesForPolicy_User>();

            for (int i = 0; i < context.Length("ListEntitiesForPolicy.Users.Length"); i++)
            {
                ListEntitiesForPolicyResponse.ListEntitiesForPolicy_User user = new ListEntitiesForPolicyResponse.ListEntitiesForPolicy_User();
                user.UserId      = context.StringValue("ListEntitiesForPolicy.Users[" + i + "].UserId");
                user.UserName    = context.StringValue("ListEntitiesForPolicy.Users[" + i + "].UserName");
                user.DisplayName = context.StringValue("ListEntitiesForPolicy.Users[" + i + "].DisplayName");
                user.AttachDate  = context.StringValue("ListEntitiesForPolicy.Users[" + i + "].AttachDate");

                listEntitiesForPolicyResponse_users.Add(user);
            }
            listEntitiesForPolicyResponse.Users = listEntitiesForPolicyResponse_users;

            List <ListEntitiesForPolicyResponse.ListEntitiesForPolicy_Role> listEntitiesForPolicyResponse_roles = new List <ListEntitiesForPolicyResponse.ListEntitiesForPolicy_Role>();

            for (int i = 0; i < context.Length("ListEntitiesForPolicy.Roles.Length"); i++)
            {
                ListEntitiesForPolicyResponse.ListEntitiesForPolicy_Role role = new ListEntitiesForPolicyResponse.ListEntitiesForPolicy_Role();
                role.RoleId      = context.StringValue("ListEntitiesForPolicy.Roles[" + i + "].RoleId");
                role.RoleName    = context.StringValue("ListEntitiesForPolicy.Roles[" + i + "].RoleName");
                role.Arn         = context.StringValue("ListEntitiesForPolicy.Roles[" + i + "].Arn");
                role.Description = context.StringValue("ListEntitiesForPolicy.Roles[" + i + "].Description");
                role.AttachDate  = context.StringValue("ListEntitiesForPolicy.Roles[" + i + "].AttachDate");

                listEntitiesForPolicyResponse_roles.Add(role);
            }
            listEntitiesForPolicyResponse.Roles = listEntitiesForPolicyResponse_roles;

            return(listEntitiesForPolicyResponse);
        }