/* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. * A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ using Amazon.S3.Model.Internal.MarshallTransformations; using System.Xml; namespace Amazon.S3.Model.Internal { /// /// Defines the interface that is used to visit all the different /// implementations of /// internal interface ILifecyclePredicateVisitor { /// /// Visit a /// /// void Visit(LifecyclePrefixPredicate lifecyclePrefixPredicate); /// /// Visit a /// /// void Visit(LifecycleTagPredicate lifecycleTagPredicate); /// /// Visit a /// /// void Visit(LifecycleObjectSizeGreaterThanPredicate lifecycleGreaterThanPredicate); /// /// Visit a /// /// void Visit(LifecycleObjectSizeLessThanPredicate lifecycleGreaterLessThanPredicate); /// /// Visit a /// /// void Visit(LifecycleAndOperator lifecycleAndOperator); } /// /// Implementation of to marshall . /// internal class LifecycleFilterPredicateMarshallVisitor : ILifecyclePredicateVisitor { private XmlWriter xmlWriter; public LifecycleFilterPredicateMarshallVisitor(XmlWriter xmlWriter) { this.xmlWriter = xmlWriter; } public void Visit(LifecyclePrefixPredicate lifecyclePrefixPredicate) { xmlWriter.WriteElementString("Prefix", S3Transforms.ToXmlStringValue(lifecyclePrefixPredicate.Prefix)); } public void Visit(LifecycleTagPredicate lifecycleTagPredicate) { xmlWriter.WriteStartElement("Tag"); if (lifecycleTagPredicate.IsSetTag()) { xmlWriter.WriteElementString("Key", S3Transforms.ToXmlStringValue(lifecycleTagPredicate.Tag.Key)); xmlWriter.WriteElementString("Value", S3Transforms.ToXmlStringValue(lifecycleTagPredicate.Tag.Value)); } xmlWriter.WriteEndElement(); } public void Visit(LifecycleObjectSizeGreaterThanPredicate lifecycleGreaterThanPredicate) { xmlWriter.WriteElementString("ObjectSizeGreaterThan", S3Transforms.ToXmlStringValue(lifecycleGreaterThanPredicate.ObjectSizeGreaterThan)); } public void Visit(LifecycleObjectSizeLessThanPredicate lifecycleGreaterLessThanPredicate) { xmlWriter.WriteElementString("ObjectSizeLessThan", S3Transforms.ToXmlStringValue(lifecycleGreaterLessThanPredicate.ObjectSizeLessThan)); } public void Visit(LifecycleAndOperator lifecycleAndOperator) { xmlWriter.WriteStartElement("And"); if (lifecycleAndOperator.IsSetOperands()) { foreach (var predicate in lifecycleAndOperator.Operands) { if (predicate != null) predicate.Accept(this); } } xmlWriter.WriteEndElement(); } } }