Пример #1
0
        private static void UnmarshallResult(XmlUnmarshallerContext context, GetBucketLoggingResponse response)
        {
            int originalDepth = context.CurrentDepth;
            int targetDepth   = originalDepth + 1;

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

            while (context.Read())
            {
                if (context.IsStartElement || context.IsAttribute)
                {
                    if (context.TestExpression("LoggingEnabled", targetDepth))
                    {
                        response.BucketLoggingConfig = LoggingEnabledUnmarshaller.GetInstance().Unmarshall(context);

                        continue;
                    }
                }
                else if (context.IsEndElement && context.CurrentDepth < originalDepth)
                {
                    return;
                }
            }



            return;
        }
Пример #2
0
        public override GetBucketLoggingResponse ParseGetBucketLoggingResponse(HttpResponse httpResponse)
        {
            GetBucketLoggingResponse response = new GetBucketLoggingResponse();

            using (XmlReader xmlReader = XmlReader.Create(httpResponse.Content))
            {
                Grant currentGrant = null;
                while (xmlReader.Read())
                {
                    if ("BucketLoggingStatus".Equals(xmlReader.Name))
                    {
                        if (xmlReader.IsStartElement())
                        {
                            response.Configuration = new LoggingConfiguration();
                        }
                    }
                    else if ("Agency".Equals(xmlReader.Name))
                    {
                        response.Configuration.Agency = xmlReader.ReadString();
                    }
                    else if ("TargetBucket".Equals(xmlReader.Name))
                    {
                        response.Configuration.TargetBucketName = xmlReader.ReadString();
                    }
                    else if ("TargetPrefix".Equals(xmlReader.Name))
                    {
                        response.Configuration.TargetPrefix = xmlReader.ReadString();
                    }
                    else if ("Grant".Equals(xmlReader.Name))
                    {
                        if (xmlReader.IsStartElement())
                        {
                            currentGrant = new Grant();
                            response.Configuration.Grants.Add(currentGrant);
                        }
                    }
                    else if ("ID".Equals(xmlReader.Name))
                    {
                        CanonicalGrantee grantee = new CanonicalGrantee();
                        grantee.Id           = xmlReader.ReadString();
                        currentGrant.Grantee = grantee;
                    }
                    else if ("Canned".Equals(xmlReader.Name))
                    {
                        GroupGrantee grantee = new GroupGrantee();
                        grantee.GroupGranteeType = this.ParseGroupGrantee(xmlReader.ReadString());
                        currentGrant.Grantee     = grantee;
                    }
                    else if ("Permission".Equals(xmlReader.Name))
                    {
                        currentGrant.Permission = this.ParsePermission(xmlReader.ReadString());
                    }
                }
            }
            return(response);
        }
        public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context)
        {
            GetBucketLoggingResponse getBucketLoggingResponse = new GetBucketLoggingResponse();

            while (context.Read())
            {
                if (context.get_IsStartElement())
                {
                    UnmarshallResult(context, getBucketLoggingResponse);
                }
            }
            return(getBucketLoggingResponse);
        }
Пример #4
0
        static void GetBucketLogging()
        {
            try
            {
                GetBucketLoggingRequest request = new GetBucketLoggingRequest
                {
                    BucketName = bucketName
                };
                GetBucketLoggingResponse response = client.GetBucketLogging(request);

                Console.WriteLine("TargetBucketName is : " + response.Configuration.TargetBucketName);
                Console.WriteLine("TargetPrefix is : " + response.Configuration.TargetPrefix);
                Console.WriteLine("Get bucket logging response: {0}", response.StatusCode);
            }
            catch (ObsException ex)
            {
                Console.WriteLine("Exception errorcode: {0}, when get bucket logging.", ex.ErrorCode);
                Console.WriteLine("Exception errormessage: {0}", ex.ErrorMessage);
            }
        }
        private static void UnmarshallResult(XmlUnmarshallerContext context, GetBucketLoggingResponse response)
        {
            int currentDepth = context.get_CurrentDepth();
            int num          = currentDepth + 1;

            if (context.get_IsStartOfDocument())
            {
                num += 2;
            }
            while (context.Read())
            {
                if (context.get_IsStartElement() || context.get_IsAttribute())
                {
                    if (context.TestExpression("LoggingEnabled", num))
                    {
                        response.BucketLoggingConfig = LoggingEnabledUnmarshaller.Instance.Unmarshall(context);
                    }
                }
                else if (context.get_IsEndElement() && context.get_CurrentDepth() < currentDepth)
                {
                    break;
                }
            }
        }