Amazon.S3.Util.S3PostUploadSignedPolicy.GetSignedPolicyFromXml C# (CSharp) Méthode

GetSignedPolicyFromXml() public static méthode

Create an instance of this class from an XML string.
public static GetSignedPolicyFromXml ( string policyXml ) : S3PostUploadSignedPolicy
policyXml string XML string generated by ToXml()
Résultat S3PostUploadSignedPolicy
        public static S3PostUploadSignedPolicy GetSignedPolicyFromXml(string policyXml)
        {
            var reader = new StringReader(policyXml);
            XmlSerializer serializer = new XmlSerializer(typeof(S3PostUploadSignedPolicy));

            S3PostUploadSignedPolicy policy;
            try
            {
                policy = serializer.Deserialize(reader) as S3PostUploadSignedPolicy;
            }
            catch (Exception e)
            {
                throw new ArgumentException("Could not parse XML", e);
            }

            if (String.IsNullOrEmpty(policy.AccessKeyId))
                throw new ArgumentException("XML Document requries 'AccessKeyId' field");
            if (String.IsNullOrEmpty(policy.Policy))
                throw new ArgumentException("XML Document requries 'Policy' field");
            if (String.IsNullOrEmpty(policy.Signature))
                throw new ArgumentException("XML Document requries 'Signature' field");

            return policy;
        }
    }