<#@ template language="C#" inherits="BaseResponseUnmarshaller"#> <#@ assembly name="System.Core" #> <#@ import namespace="System.Linq" #> <#@ import namespace="System.Text" #> <#@ import namespace="System.Collections.Generic" #> <# AddLicenseHeader(); AddCommonUsingStatements(); #> namespace <#=this.Config.Namespace #>.Model.Internal.MarshallTransformations { /// /// Response Unmarshaller for <#=this.UnmarshallerBaseName #> operation /// public class <#=this.UnmarshallerBaseName #>Unmarshaller : IErrorResponseUnmarshaller<<#=this.UnmarshallerBaseName #>, XmlUnmarshallerContext> { /// /// Unmarshaller the response from the service to the response class. /// /// /// public <#=this.UnmarshallerBaseName #> Unmarshall(XmlUnmarshallerContext context) { return this.Unmarshall(context, new Amazon.Runtime.Internal.ErrorResponse()); } /// /// Unmarshaller error response to exception. /// /// /// /// public <#=this.UnmarshallerBaseName #> Unmarshall(XmlUnmarshallerContext context, Amazon.Runtime.Internal.ErrorResponse errorResponse) { <#=this.UnmarshallerBaseName #> response = new <#=this.UnmarshallerBaseName #>(errorResponse.Message, errorResponse.InnerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, errorResponse.StatusCode); int originalDepth = context.CurrentDepth; int targetDepth = originalDepth + 1; if (context.IsStartOfDocument) targetDepth += 2; while (context.ReadAtDepth(originalDepth)) { if (context.IsStartElement || context.IsAttribute) { <# if(this.Structure != null) { foreach (var member in this.Structure.Members) { var testExpression = GeneratorHelpers.DetermineAWSQueryTestExpression(member); #> if (context.TestExpression("<#=testExpression#>", targetDepth)) { <# if (member.IsMap || member.IsList) { #> var item = <#= member.DetermineTypeUnmarshallerInstantiate() #>.Unmarshall(context); response.<#=MemberAccessorFor(member.PropertyName)#>.Add(item); <# } else { #> response.<#=MemberAccessorFor(member.PropertyName)#> = <#= member.DetermineTypeUnmarshallerInstantiate() #>.Unmarshall(context); <# } #> } <# } } #> } } return response; } <# this.AddStructureSingletonMethod(); #> } } <#+ // if the result fields have been wrapped in a subordinate structure, wire the accessor // to use it when addressing a member string MemberAccessorFor(string memberName) { if (string.IsNullOrEmpty(WrappedResultMember)) return memberName; return string.Concat(WrappedResultMember, ".", memberName); } #>