// ------------------------------------------------------------------------------ // // This code was generated by a tool. // Runtime Version: 17.0.0.0 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // // ------------------------------------------------------------------------------ namespace ServiceClientGenerator.Generators.Marshallers { using System.Linq; using System.Text; using System.Collections.Generic; using System; /// /// Class to produce the template output /// #line 1 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt" [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "17.0.0.0")] public partial class RestXmlResponseUnmarshaller : BaseResponseUnmarshaller { #line hidden /// /// Create the template output /// public override string TransformText() { #line 6 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt" AddLicenseHeader(); AddCommonUsingStatements(); #line default #line hidden this.Write("\r\nnamespace "); #line 12 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt" this.Write(this.ToStringHelper.ToStringWithCulture(this.Config.Namespace)); #line default #line hidden this.Write(".Model.Internal.MarshallTransformations\r\n{\r\n /// \r\n /// Response U" + "nmarshaller for "); #line 15 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt" this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName)); #line default #line hidden this.Write(" operation\r\n /// \r\n public class "); #line 17 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt" this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName)); #line default #line hidden this.Write(@"ResponseUnmarshaller : XmlResponseUnmarshaller { /// /// Unmarshaller the response from the service to the response class. /// /// /// public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context) { "); #line 26 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt" this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName)); #line default #line hidden this.Write("Response response = new "); #line 26 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt" this.Write(this.ToStringHelper.ToStringWithCulture(this.Operation.Name)); #line default #line hidden this.Write("Response();\r\n"); #line 27 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt" var payload= this.Operation.ResponsePayloadMember; var shouldMarshallPayload = (payload != null && payload.IsStructure); var payloadIsStream = (payload != null && !shouldMarshallPayload); if (this.Operation.ResponseHasBodyMembers || shouldMarshallPayload) { if (this.Operation.AllowEmptyResult) { #line default #line hidden this.Write(" if (context.ResponseData.IsSuccessStatusCode && context.ResponseData." + "ContentLength == 0)\r\n return response;\r\n"); #line 38 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt" } foreach (var marshallName in this.Structure.FindMarshallNamesWithoutMembers()) { #line default #line hidden this.Write("\t\t\tcontext.AllowEmptyElementLookup.Add(\""); #line 44 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt" this.Write(this.ToStringHelper.ToStringWithCulture(marshallName)); #line default #line hidden this.Write("\");\r\n"); #line 45 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt" } #line default #line hidden this.Write(" UnmarshallResult(context,response);\r\n"); #line 49 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt" } else if (payloadIsStream) { if (payload.IsStreaming) { #line default #line hidden this.Write(" response."); #line 56 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt" this.Write(this.ToStringHelper.ToStringWithCulture(payload.PropertyName)); #line default #line hidden this.Write(" = context.Stream;\r\n"); #line 57 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt" } else if (payload.ModelShape.IsString) { #line default #line hidden this.Write(" using (var sr = new StreamReader(context.Stream))\r\n {\r\n " + " response."); #line 64 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt" this.Write(this.ToStringHelper.ToStringWithCulture(payload.PropertyName)); #line default #line hidden this.Write(" = sr.ReadToEnd();\r\n }\r\n"); #line 66 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt" } else if (payload.ModelShape.IsMemoryStream) { #line default #line hidden this.Write("\r\n var ms = new MemoryStream();\r\n Amazon.Util.AWSSDKUtils.C" + "opyStream(context.Stream, ms);\r\n ms.Seek(0, SeekOrigin.Begin);\r\n " + " response."); #line 75 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt" this.Write(this.ToStringHelper.ToStringWithCulture(payload.PropertyName)); #line default #line hidden this.Write(" = ms;\r\n\r\n"); #line 77 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt" } else { // At this point, all valid configurations have been handled. Valid use of payload is defined: // https://awslabs.github.io/smithy/1.0/spec/core/http-traits.html#httppayload-trait throw new Exception( $"{payload.PropertyName} can not be a Payload as Type {payload.Shape.Type} is not a valid target for the httpPayload trait. " + "The httpPayload trait can be applied to structure members that target a string, blob, structure, union, document, set, map, or list."); } } UnmarshallHeaders(); ProcessStatusCode(); #line default #line hidden this.Write(" \r\n return response;\r\n\t\t}\t\t\r\n"); #line 93 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt" if ( this.Operation.ResponseHasBodyMembers || shouldMarshallPayload) { #line default #line hidden this.Write("\r\n"); #line 98 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt" if (this.Operation.ResponseBodyMembers.Count == 0 && !shouldMarshallPayload) { #line default #line hidden this.Write("\t\t[System.Diagnostics.CodeAnalysis.SuppressMessage(\"Microsoft.Usage\", \"CA1801:Rev" + "iewUnusedParameters\", MessageId=\"response\")]\r\n"); #line 103 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt" } #line default #line hidden this.Write("\t\tprivate static void UnmarshallResult(XmlUnmarshallerContext context, "); #line 106 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt" this.Write(this.ToStringHelper.ToStringWithCulture(this.Operation.Name)); #line default #line hidden this.Write("Response response)\r\n {\r\n int originalDepth = context.CurrentDep" + "th;\r\n int targetDepth = originalDepth + 1;\r\n"); #line 110 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt" if (payload == null) { #line default #line hidden this.Write("\t\t\tif (context.IsStartOfDocument) \r\n\t\t\t\t targetDepth += 1;\r\n"); #line 116 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt" } #line default #line hidden this.Write("\r\n while (context.Read())\r\n {\r\n\t\t\t\tif (context.IsStartEleme" + "nt || context.IsAttribute)\r\n {\r\n"); #line 124 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt" foreach (var member in this.Operation.ResponseBodyMembers) { if (member.Shape.IsList) { var listMarshallName = member.Shape.ListMarshallName ?? "member"; if (member.Shape.IsFlattened) { #line default #line hidden this.Write("\t\t\t\t\tif (context.TestExpression(\""); #line 134 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt" this.Write(this.ToStringHelper.ToStringWithCulture(listMarshallName)); #line default #line hidden this.Write("\", targetDepth))\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tvar unmarshaller = "); #line 136 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt" this.Write(this.ToStringHelper.ToStringWithCulture(member.DetermineTypeUnmarshallerInstantiate())); #line default #line hidden this.Write(";\r\n\t\t\t\t\t\tresponse."); #line 137 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt" this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName)); #line default #line hidden this.Write(".Add(unmarshaller.Unmarshall(context));\r\n\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t}\r\n"); #line 140 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt" } else { #line default #line hidden this.Write("\t\t\t\t if (context.TestExpression(\""); #line 147 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt" this.Write(this.ToStringHelper.ToStringWithCulture(member.MarshallName)); #line default #line hidden this.Write("/"); #line 147 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt" this.Write(this.ToStringHelper.ToStringWithCulture(listMarshallName)); #line default #line hidden this.Write("\", targetDepth))\r\n\t\t\t\t {\r\n\t\t\t\t\t var unmarshaller = "); #line 149 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt" this.Write(this.ToStringHelper.ToStringWithCulture(member.DetermineTypeUnmarshallerInstantiate())); #line default #line hidden this.Write(";\r\n\t\t\t\t\t response."); #line 150 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt" this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName)); #line default #line hidden this.Write(".Add(unmarshaller.Unmarshall(context));\r\n\t\t\t\t\t continue;\r\n\t\t\t\t }\r\n"); #line 153 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt" } } else { #line default #line hidden this.Write("\t\t\t\t\tif (context.TestExpression(\""); #line 159 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt" this.Write(this.ToStringHelper.ToStringWithCulture(member.MarshallName)); #line default #line hidden this.Write("\", targetDepth))\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tvar unmarshaller = "); #line 161 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt" this.Write(this.ToStringHelper.ToStringWithCulture(member.DetermineTypeUnmarshallerInstantiate())); #line default #line hidden this.Write(";\r\n\t\t\t\t\t\tresponse."); #line 162 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt" this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName)); #line default #line hidden this.Write(" = unmarshaller.Unmarshall(context);\r\n\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t}\r\n"); #line 165 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt" } } if (shouldMarshallPayload) { #line default #line hidden this.Write("\t\t\t\t\tif (context.TestExpression(\""); #line 172 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt" this.Write(this.ToStringHelper.ToStringWithCulture(payload.MarshallName)); #line default #line hidden this.Write("\", targetDepth))\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tvar unmarshaller = "); #line 174 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt" this.Write(this.ToStringHelper.ToStringWithCulture(payload.DetermineTypeUnmarshallerInstantiate())); #line default #line hidden this.Write(";\r\n\t\t\t\t\t\tresponse."); #line 175 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt" this.Write(this.ToStringHelper.ToStringWithCulture(payload.PropertyName)); #line default #line hidden this.Write(" = unmarshaller.Unmarshall(context);\r\n\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t}\r\n"); #line 178 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt" } #line default #line hidden this.Write("\t\t\t\t}\r\n\t\t\t\telse if (context.IsEndElement && context.CurrentDepth < originalDepth)" + "\r\n {\r\n return;\r\n }\r\n " + " }\r\n \r\n return;\r\n }\r\n"); #line 190 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt" } #line default #line hidden this.Write(@" /// /// Unmarshaller error response to exception. /// /// /// /// /// public override AmazonServiceException UnmarshallException(XmlUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode) { ErrorResponse errorResponse = ErrorResponseUnmarshaller.GetInstance().Unmarshall(context); errorResponse.InnerException = innerException; errorResponse.StatusCode = statusCode; var responseBodyBytes = context.GetResponseBodyBytes(); using (var streamCopy = new MemoryStream(responseBodyBytes)) using (var contextCopy = new XmlUnmarshallerContext(streamCopy, false, null)) { "); #line 212 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt" foreach (var exception in this.Operation.Exceptions) { #line default #line hidden this.Write(" if (errorResponse.Code != null && errorResponse.Code.Equals(\""); #line 216 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt" this.Write(this.ToStringHelper.ToStringWithCulture(exception.Code)); #line default #line hidden this.Write("\"))\r\n {\r\n return "); #line 218 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt" this.Write(this.ToStringHelper.ToStringWithCulture(exception.Name)); #line default #line hidden this.Write("Unmarshaller.Instance.Unmarshall(contextCopy, errorResponse);\r\n }\r" + "\n"); #line 220 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt" } #line default #line hidden this.Write(" }\r\n return new "); #line 224 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt" this.Write(this.ToStringHelper.ToStringWithCulture(this.BaseException)); #line default #line hidden this.Write("(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, e" + "rrorResponse.RequestId, statusCode);\r\n }\r\n\r\n"); #line 227 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlResponseUnmarshaller.tt" this.AddResponseSingletonMethod(); #line default #line hidden this.Write(" }\r\n}"); return this.GenerationEnvironment.ToString(); } } #line default #line hidden }