PageRenderTime 48ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/generator/ServiceClientGeneratorLib/Generators/Marshallers/BaseResponseUnmarshaller.cs

https://gitlab.com/vectorci/aws-sdk-net
C# | 366 lines | 215 code | 127 blank | 24 comment | 8 complexity | 3ed757a64e7e7df60902617c524f5930 MD5 | raw file
  1. // ------------------------------------------------------------------------------
  2. // <auto-generated>
  3. // This code was generated by a tool.
  4. // Runtime Version: 12.0.0.0
  5. //
  6. // Changes to this file may cause incorrect behavior and will be lost if
  7. // the code is regenerated.
  8. // </auto-generated>
  9. // ------------------------------------------------------------------------------
  10. namespace ServiceClientGenerator.Generators.Marshallers
  11. {
  12. using System.Linq;
  13. using System.Text;
  14. using System.Collections.Generic;
  15. using System;
  16. /// <summary>
  17. /// Class to produce the template output
  18. /// </summary>
  19. #line 1 "C:\Codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\BaseResponseUnmarshaller.tt"
  20. [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "12.0.0.0")]
  21. public partial class BaseResponseUnmarshaller : Generators.BaseGenerator
  22. {
  23. #line hidden
  24. /// <summary>
  25. /// Create the template output
  26. /// </summary>
  27. public override string TransformText()
  28. {
  29. this.Write("\r\n");
  30. return this.GenerationEnvironment.ToString();
  31. }
  32. #line 7 "C:\Codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\BaseResponseUnmarshaller.tt"
  33. protected void AddCommonUsingStatements()
  34. {
  35. #line default
  36. #line hidden
  37. #line 10 "C:\Codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\BaseResponseUnmarshaller.tt"
  38. this.Write("using System;\r\nusing System.Collections.Generic;\r\nusing System.Globalization;\r\nus" +
  39. "ing System.IO;\r\nusing System.Net;\r\nusing System.Text;\r\nusing System.Xml.Serializ" +
  40. "ation;\r\n\r\nusing ");
  41. #line default
  42. #line hidden
  43. #line 19 "C:\Codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\BaseResponseUnmarshaller.tt"
  44. this.Write(this.ToStringHelper.ToStringWithCulture(this.Config.Namespace));
  45. #line default
  46. #line hidden
  47. #line 19 "C:\Codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\BaseResponseUnmarshaller.tt"
  48. this.Write(".Model;\r\nusing Amazon.Runtime;\r\nusing Amazon.Runtime.Internal;\r\nusing Amazon.Runt" +
  49. "ime.Internal.Transform;\r\nusing Amazon.Runtime.Internal.Util;\r\n");
  50. #line default
  51. #line hidden
  52. #line 24 "C:\Codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\BaseResponseUnmarshaller.tt"
  53. }
  54. // Set to true when the service model specifies a shape that should be wrapped in a response. ElastiCache CreateCacheCluster is an example of this.
  55. public bool IsWrapped { get; set; }
  56. // set to the name of the member in the base Result class for operations where response data is moved from the result
  57. // class into a structure member. If not set, the response members are assumed to be in the result base class itself.
  58. public string WrappedResultMember { get; set; }
  59. // The operation to unmarshall a response from
  60. public Operation Operation { get; set; }
  61. Shape _structure;
  62. // Set if we are generating what is effectively a void response from an operation - no result class or other
  63. // members were generated
  64. public bool HasSuppressedResult { get; set; }
  65. public string BaseException { get; set; }
  66. // The shape of the response
  67. public Shape Structure
  68. {
  69. get
  70. {
  71. if(this.Operation != null)
  72. {
  73. if(this.Operation.IsResponseWrapped)
  74. return this.Operation.ResponseStructure.Members[0].Shape;
  75. else
  76. return this.Operation.ResponseStructure;
  77. }
  78. return this._structure;
  79. }
  80. set { this._structure = value; }
  81. }
  82. public string UnmarshallerBaseName
  83. {
  84. get
  85. {
  86. if(this.Operation != null)
  87. return this.Operation.Name;
  88. return this.Structure.Name;
  89. }
  90. }
  91. protected void AddResponseSingletonMethod()
  92. {
  93. #line default
  94. #line hidden
  95. #line 75 "C:\Codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\BaseResponseUnmarshaller.tt"
  96. this.Write(" private static ");
  97. #line default
  98. #line hidden
  99. #line 76 "C:\Codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\BaseResponseUnmarshaller.tt"
  100. this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName));
  101. #line default
  102. #line hidden
  103. #line 76 "C:\Codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\BaseResponseUnmarshaller.tt"
  104. this.Write("ResponseUnmarshaller _instance = new ");
  105. #line default
  106. #line hidden
  107. #line 76 "C:\Codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\BaseResponseUnmarshaller.tt"
  108. this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName));
  109. #line default
  110. #line hidden
  111. #line 76 "C:\Codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\BaseResponseUnmarshaller.tt"
  112. this.Write("ResponseUnmarshaller(); \r\n\r\n\t\tinternal static ");
  113. #line default
  114. #line hidden
  115. #line 78 "C:\Codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\BaseResponseUnmarshaller.tt"
  116. this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName));
  117. #line default
  118. #line hidden
  119. #line 78 "C:\Codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\BaseResponseUnmarshaller.tt"
  120. this.Write("ResponseUnmarshaller GetInstance()\r\n\t\t{\r\n\t\t\treturn _instance;\r\n\t\t}\r\n\r\n ///" +
  121. " <summary>\r\n /// Gets the singleton.\r\n /// </summary> \r\n\t\tpublic " +
  122. "static ");
  123. #line default
  124. #line hidden
  125. #line 86 "C:\Codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\BaseResponseUnmarshaller.tt"
  126. this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName));
  127. #line default
  128. #line hidden
  129. #line 86 "C:\Codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\BaseResponseUnmarshaller.tt"
  130. this.Write("ResponseUnmarshaller Instance\r\n\t\t{\r\n\t\t\tget\r\n\t\t\t{\r\n\t\t\t\treturn _instance;\r\n\t\t\t}\r\n\t\t" +
  131. "}\r\n\r\n");
  132. #line default
  133. #line hidden
  134. #line 94 "C:\Codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\BaseResponseUnmarshaller.tt"
  135. }
  136. protected void AddStructureSingletonMethod()
  137. {
  138. #line default
  139. #line hidden
  140. #line 99 "C:\Codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\BaseResponseUnmarshaller.tt"
  141. this.Write(" private static ");
  142. #line default
  143. #line hidden
  144. #line 100 "C:\Codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\BaseResponseUnmarshaller.tt"
  145. this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName));
  146. #line default
  147. #line hidden
  148. #line 100 "C:\Codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\BaseResponseUnmarshaller.tt"
  149. this.Write("Unmarshaller _instance = new ");
  150. #line default
  151. #line hidden
  152. #line 100 "C:\Codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\BaseResponseUnmarshaller.tt"
  153. this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName));
  154. #line default
  155. #line hidden
  156. #line 100 "C:\Codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\BaseResponseUnmarshaller.tt"
  157. this.Write("Unmarshaller(); \r\n\r\n /// <summary>\r\n /// Gets the singleton." +
  158. "\r\n /// </summary> \r\n\t\tpublic static ");
  159. #line default
  160. #line hidden
  161. #line 105 "C:\Codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\BaseResponseUnmarshaller.tt"
  162. this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName));
  163. #line default
  164. #line hidden
  165. #line 105 "C:\Codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\BaseResponseUnmarshaller.tt"
  166. this.Write("Unmarshaller Instance\r\n\t\t{\r\n\t\t\tget\r\n\t\t\t{\r\n\t\t\t\treturn _instance;\r\n\t\t\t}\r\n\t\t}\r\n");
  167. #line default
  168. #line hidden
  169. #line 112 "C:\Codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\BaseResponseUnmarshaller.tt"
  170. }
  171. // Generates code to parse present header members into the response object
  172. protected void UnmarshallHeaders()
  173. {
  174. if( this.Operation.ResponseHeaderMembers.Count() > 0 )
  175. {
  176. foreach (var member in this.Operation.ResponseHeaderMembers)
  177. {
  178. #line default
  179. #line hidden
  180. #line 122 "C:\Codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\BaseResponseUnmarshaller.tt"
  181. this.Write("\t\t\tif (context.ResponseData.IsHeaderPresent(\"");
  182. #line default
  183. #line hidden
  184. #line 123 "C:\Codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\BaseResponseUnmarshaller.tt"
  185. this.Write(this.ToStringHelper.ToStringWithCulture(member.MarshallLocationName));
  186. #line default
  187. #line hidden
  188. #line 123 "C:\Codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\BaseResponseUnmarshaller.tt"
  189. this.Write("\"))\r\n\t\t\t\tresponse.");
  190. #line default
  191. #line hidden
  192. #line 124 "C:\Codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\BaseResponseUnmarshaller.tt"
  193. this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName));
  194. #line default
  195. #line hidden
  196. #line 124 "C:\Codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\BaseResponseUnmarshaller.tt"
  197. this.Write(" = context.ResponseData.GetHeaderValue(\"");
  198. #line default
  199. #line hidden
  200. #line 124 "C:\Codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\BaseResponseUnmarshaller.tt"
  201. this.Write(this.ToStringHelper.ToStringWithCulture(member.MarshallLocationName));
  202. #line default
  203. #line hidden
  204. #line 124 "C:\Codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\BaseResponseUnmarshaller.tt"
  205. this.Write("\");\r\n");
  206. #line default
  207. #line hidden
  208. #line 125 "C:\Codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\BaseResponseUnmarshaller.tt"
  209. }
  210. }
  211. }
  212. // Generates code to set the status code of the response, example: 404, 200, etc
  213. protected void ProcessStatusCode()
  214. {
  215. if( this.Operation.ResponseStatusCodeMember != null)
  216. {
  217. #line default
  218. #line hidden
  219. #line 135 "C:\Codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\BaseResponseUnmarshaller.tt"
  220. this.Write("\t\t\tresponse.");
  221. #line default
  222. #line hidden
  223. #line 136 "C:\Codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\BaseResponseUnmarshaller.tt"
  224. this.Write(this.ToStringHelper.ToStringWithCulture(this.Operation.ResponseStatusCodeMember.PropertyName));
  225. #line default
  226. #line hidden
  227. #line 136 "C:\Codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\BaseResponseUnmarshaller.tt"
  228. this.Write(" = (int)context.ResponseData.StatusCode;\r\n");
  229. #line default
  230. #line hidden
  231. #line 137 "C:\Codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\BaseResponseUnmarshaller.tt"
  232. }
  233. }
  234. #line default
  235. #line hidden
  236. }
  237. #line default
  238. #line hidden
  239. }