コード例 #1
0
ファイル: S3Grant.cs プロジェクト: nschnarr/awssdk
        internal string ToXML()
        {
            StringBuilder sb = new StringBuilder(1024);

            sb.Append("<Grant>");
            if (Grantee.IsSetCanonicalUser())
            {
                sb.Append("<Grantee xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"CanonicalUser\">");
                sb.Append("<ID>").Append(SecurityElement.Escape(this.Grantee.CanonicalUser.First)).Append("</ID>");
                sb.Append("<DisplayName>").Append(SecurityElement.Escape(this.Grantee.CanonicalUser.Second)).Append("</DisplayName>");
                sb.Append("</Grantee>");
                sb.Append("<Permission>").Append(this.Permission).Append("</Permission>");
            }
            else if (this.Grantee.IsSetEmailAddress())
            {
                sb.Append("<Grantee xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"AmazonCustomerByEmail\">");
                sb.Append("<EmailAddress>").Append(SecurityElement.Escape(this.Grantee.EmailAddress)).Append("</EmailAddress>");
                sb.Append("</Grantee>");
                sb.Append("<Permission>").Append(this.Permission).Append("</Permission>");
            }
            else if (this.Grantee.IsSetURI())
            {
                sb.Append("<Grantee xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"Group\">");
                sb.Append("<URI>").Append(SecurityElement.Escape(this.Grantee.URI)).Append("</URI>");
                sb.Append("</Grantee>");
                sb.Append("<Permission>").Append(this.Permission).Append("</Permission>");
            }
            sb.Append("</Grant>");

            return(sb.ToString());
        }
コード例 #2
0
ファイル: S3Grant.cs プロジェクト: subhadlearner/aws-sdk-net
        internal void Marshall(string memberName, XmlWriter xmlWriter)
        {
            xmlWriter.WriteStartElement(memberName);
            {
                if (Grantee != null)
                {
                    xmlWriter.WriteStartElement("Grantee");
                    if (Grantee.IsSetType())
                    {
                        xmlWriter.WriteAttributeString("xsi", "type",
                                                       "http://www.w3.org/2001/XMLSchema-instance",
                                                       Grantee.Type.ToString());
                    }
                    if (Grantee.IsSetDisplayName())
                    {
                        xmlWriter.WriteElementString("DisplayName",
                                                     S3Transforms.ToXmlStringValue(
                                                         Grantee.DisplayName));
                    }
                    if (Grantee.IsSetEmailAddress())
                    {
                        xmlWriter.WriteElementString("EmailAddress",
                                                     S3Transforms.ToXmlStringValue(
                                                         Grantee.EmailAddress));
                    }
                    if (Grantee.IsSetCanonicalUser())
                    {
                        xmlWriter.WriteElementString("ID",
                                                     S3Transforms.ToXmlStringValue(
                                                         Grantee.CanonicalUser));
                    }
                    if (Grantee.IsSetURI())
                    {
                        xmlWriter.WriteElementString("URI",
                                                     S3Transforms.ToXmlStringValue(
                                                         Grantee.URI));
                    }
                    xmlWriter.WriteEndElement();
                }

                if (IsSetPermission())
                {
                    xmlWriter.WriteElementString("Permission",
                                                 S3Transforms.ToXmlStringValue(
                                                     Permission));
                }
            }
            xmlWriter.WriteEndElement();
        }