/// <summary> /// Generate the response class for the operation. /// </summary> /// <param name="operation">The operation object which contains info about what the response needs to contain for the operation</param> private void GenerateResponse(Operation operation) { var suppressResultGeneration = false; if (operation.UseWrappingResult) { // response members will be demoted to a structure contained by a // result container class (that is not in the service model) var className = operation.Name + "Response"; string propertyName = null; var propertyModifier = this.Configuration.ServiceModel.Customizations.GetPropertyModifier(className, operation.ResponseStructure.Name); if (propertyModifier != null && propertyModifier.EmitName != null) propertyName = propertyModifier.EmitName; else propertyName = operation.ResponseStructure.Name; var resultGenerator = new WrappingResultGenerator { Operation = operation, ClassName = className, BaseClass = "AmazonWebServiceResponse", Structure = this.Configuration.ServiceModel.FindShape(operation.ResponseStructure.Name), PropertyName = propertyName }; // emit the wrapping result but do not mark the shape as processed as a consequence this.ExecuteGenerator(resultGenerator, resultGenerator.ClassName + ".cs", "Model"); DetermineStructuresToProcess(resultGenerator.Structure, true); } else { // if the operation has a suppressed result modification, use the structure generator to emit // an empty xxxxResponse class, derived from AmazonWebServiceResponse suppressResultGeneration = operation.ResponseStructure == null || this.Configuration.ServiceModel.Customizations.ResultGenerationSuppressions.Contains(operation.Name); if (suppressResultGeneration) { var responseGenerator = new StructureGenerator { ClassName = operation.Name + "Response", BaseClass = "AmazonWebServiceResponse", Operation = operation }; this.ExecuteGenerator(responseGenerator, responseGenerator.ClassName + ".cs", "Model"); } else { var resultGenerator = new StructureGenerator { ClassName = operation.Name + "Response", BaseClass = "AmazonWebServiceResponse", IsWrapped = operation.IsResponseWrapped }; if (operation.ResponseStructure != null) { if (operation.IsResponseWrapped) { // If IsResponseWrapped is true, the operation.ResponseStructure will point to a // the shape with same name as ResponseWrapper. var resultShape = this.Configuration.ServiceModel.FindShape(operation.ResponseStructure.Name); var innerShape = resultShape.Members[0].Shape; resultGenerator.Structure = innerShape; } else { resultGenerator.Structure = this.Configuration.ServiceModel.FindShape(operation.ResponseStructure.Name); } } this.ExecuteGenerator(resultGenerator, resultGenerator.ClassName + ".cs", "Model"); } if (operation.ResponseStructure != null) { this.DetermineStructuresToProcess(operation.ResponseStructure, false); } } //if (!suppressResultGeneration) //{ // if (operation.ResponseStructure != null) // { // // Mark the shape as processed if it's being referred only as operation's // // output shape and not being referred directly by any other shape or via an // // operation modifier generating an artifical structure not in the service model. // if (!IsShapeReferred(operation.ResponseStructure.Name, this.Configuration.ServiceModel) // && !operation.WrapsResultShape(operation.ResponseStructure.Name)) // this._processedStructures.Add(operation.ResponseStructure.Name); // } // // This generates the legacy response class which just extends from the result class. // var responseGenerator = new LegacyResponseClass() // { // OperationName = operation.Name // }; // this.ExecuteGenerator(responseGenerator, operation.Name + "Response.cs", "Model"); //} }
/// <summary> /// Generates all the POCOs that go in the Model namespace for the structures defined in the service model. /// </summary> void GenerateStructures() { var excludedOperations = Configuration.ServiceModel.ExcludedOperations; foreach (var definition in this._structuresToProcess) { // Skip structures that have already been generated for the parent model if (IsShapePresentInParentModel(this.Configuration, definition.Name)) continue; if (!this._processedStructures.Contains(definition.Name) && !definition.IsException) { // if the shape had a substitution, we can skip generation if (this.Configuration.ServiceModel.Customizations.IsSubstitutedShape(definition.Name)) continue; // if the shape is a request or response type and the parent operation // was excluded, then skip generation var opName = definition.RelatedOperationName; if (!string.IsNullOrEmpty(opName) && excludedOperations.Contains(opName)) continue; var generator = new StructureGenerator() { ClassName = definition.Name, Structure = definition }; this.ExecuteGenerator(generator, definition.Name + ".cs", "Model"); this._processedStructures.Add(definition.Name); } } }
/// <summary> /// Generates the request class for the operation. /// </summary> /// <param name="operation">The operation object which contains info about what the request needs to contain for the operation</param> void GenerateRequest(Operation operation) { var requestGenerator = new StructureGenerator { ClassName = operation.Name + "Request", BaseClass = string.Format("Amazon{0}Request", Configuration.BaseName), StructureType = StructureType.Request, Operation = operation }; if (operation.RequestStructure != null) { requestGenerator.Structure = this.Configuration.ServiceModel.FindShape(operation.RequestStructure.Name); } this.ExecuteGenerator(requestGenerator, requestGenerator.ClassName + ".cs", "Model"); if (operation.RequestStructure != null) this.DetermineStructuresToProcess(operation.RequestStructure, false); }