/// <summary> /// Generates the request marshaller. /// </summary> /// <param name="operation">The operation to generate request marshallers for</param> void GenerateRequestMarshaller(Operation operation) { bool hasRequest = operation.RequestStructure != null; bool normalizeMarshallers; BaseRequestMarshaller generator; GetRequestMarshaller(out generator, out normalizeMarshallers); generator.Operation = operation; this.ExecuteGenerator(generator, operation.Name + "RequestMarshaller.cs", "Model.Internal.MarshallTransformations"); if (hasRequest) { this.processedMarshallers.Add(operation.RequestStructure.Name); } if (normalizeMarshallers && hasRequest) { var lookup = new NestedStructureLookup(); lookup.SearchForNestedStructures(operation.RequestStructure); foreach (var nestedStructure in lookup.NestedStructures) { if (!this.processedMarshallers.Contains(nestedStructure.Name)) { var structureGenerator = GetStructureMarshaller(); structureGenerator.Structure = nestedStructure; this.ExecuteGenerator(structureGenerator, nestedStructure.Name + "Marshaller.cs", "Model.Internal.MarshallTransformations"); //this.processedUnmarshallers.Add(nestedStructure.Name); } } } }
/// <summary> /// Generates the response unmarshaller along with any dependent structure unmarshallers that are called by this response unmarshaller. /// </summary> /// <param name="operation">The operation to generate the unmarshaller for</param> void GenerateResponseUnmarshaller(Operation operation) { { var generator = GetResponseUnmarshaller(); generator.Operation = operation; generator.IsWrapped = operation.IsResponseWrapped; generator.HasSuppressedResult = this.config.ServiceModel.Customizations.ResultGenerationSuppressions.Contains(operation.Name); var modifier = operation.model.Customizations.GetOperationModifiers(operation.Name); if (modifier != null) { // can use wrapped member to effect a rename, even though we don't push response // members down into a wrapped class generator.WrappedResultMember = modifier.WrappedResultMember; generator.IsWrapped = modifier.UseWrappingResult; } this.ExecuteGenerator(generator, operation.Name + "ResponseUnmarshaller.cs", "Model.Internal.MarshallTransformations"); // Add to the list of processed unmarshallers so we don't attempt to generate a generic structure unmarshaller. 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.config.ServiceModel) && !operation.WrapsResultShape(operation.ResponseStructure.Name)) { this.processedUnmarshallers.Add(operation.ResponseStructure.Name); } } } if (operation.ResponseStructure != null) { var lookup = new NestedStructureLookup(); lookup.SearchForNestedStructures(operation.ResponseStructure); foreach (var nestedStructure in lookup.NestedStructures) { if (this.config.ServiceModel.Customizations.IsSubstitutedShape(nestedStructure.Name)) { continue; } // Skip already processed unmarshallers. This handles the case of structures being returned in mulitiple requests. if (!this.processedUnmarshallers.Contains(nestedStructure.Name)) { var generator = GetStructureUnmarshaller(); generator.Structure = nestedStructure; this.ExecuteGenerator(generator, nestedStructure.Name + "Unmarshaller.cs", "Model.Internal.MarshallTransformations"); this.processedUnmarshallers.Add(nestedStructure.Name); } else { //throw new Exception(); } } } }
/// <summary> /// Generates the response unmarshaller along with any dependent structure unmarshallers that are called by this response unmarshaller. /// </summary> /// <param name="operation">The operation to generate the unmarshaller for</param> void GenerateResponseUnmarshaller(Operation operation) { { var baseException = string.Format("Amazon{0}Exception", this.Configuration.IsChildConfig ? this.Configuration.ParentConfig.BaseName : this.Configuration.BaseName); var generator = GetResponseUnmarshaller(); generator.Operation = operation; generator.IsWrapped = operation.IsResponseWrapped; generator.HasSuppressedResult = this.Configuration.ServiceModel.Customizations.ResultGenerationSuppressions.Contains(operation.Name); generator.BaseException = baseException; var modifier = operation.model.Customizations.GetOperationModifiers(operation.Name); if (modifier != null) { // can use wrapped member to effect a rename, even though we don't push response // members down into a wrapped class generator.WrappedResultMember = modifier.WrappedResultMember; generator.IsWrapped = modifier.UseWrappingResult; } this.ExecuteGenerator(generator, operation.Name + "ResponseUnmarshaller.cs", "Model.Internal.MarshallTransformations"); // Add to the list of processed unmarshallers so we don't attempt to generate a generic structure unmarshaller. 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._processedUnmarshallers.Add(operation.ResponseStructure.Name); } } if (operation.ResponseStructure != null) { var lookup = new NestedStructureLookup(); lookup.SearchForNestedStructures(operation.ResponseStructure); foreach (var nestedStructure in lookup.NestedStructures) { // Skip structure unmarshallers that have already been generated for the parent model if (IsShapePresentInParentModel(this.Configuration, nestedStructure.Name)) continue; if (this.Configuration.ServiceModel.Customizations.IsSubstitutedShape(nestedStructure.Name)) continue; // Skip already processed unmarshallers. This handles the case of structures being returned in mulitiple requests. if (!this._processedUnmarshallers.Contains(nestedStructure.Name)) { var generator = GetStructureUnmarshaller(); generator.Structure = nestedStructure; this.ExecuteGenerator(generator, nestedStructure.Name + "Unmarshaller.cs", "Model.Internal.MarshallTransformations"); this._processedUnmarshallers.Add(nestedStructure.Name); } else { //throw new Exception(); } } } }
/// <summary> /// Generates the request marshaller. /// </summary> /// <param name="operation">The operation to generate request marshallers for</param> void GenerateRequestMarshaller(Operation operation) { bool hasRequest = operation.RequestStructure != null; bool normalizeMarshallers; BaseRequestMarshaller generator; GetRequestMarshaller(out generator, out normalizeMarshallers); generator.Operation = operation; this.ExecuteGenerator(generator, operation.Name + "RequestMarshaller.cs", "Model.Internal.MarshallTransformations"); if (hasRequest) this._processedMarshallers.Add(operation.RequestStructure.Name); if (normalizeMarshallers && hasRequest) { var lookup = new NestedStructureLookup(); lookup.SearchForNestedStructures(operation.RequestStructure); foreach (var nestedStructure in lookup.NestedStructures) { // Skip structure marshallers that have already been generated for the parent model if (IsShapePresentInParentModel(this.Configuration, nestedStructure.Name)) continue; if (!this._processedMarshallers.Contains(nestedStructure.Name)) { var structureGenerator = GetStructureMarshaller(); structureGenerator.Structure = nestedStructure; this.ExecuteGenerator(structureGenerator, nestedStructure.Name + "Marshaller.cs", "Model.Internal.MarshallTransformations"); //this.processedUnmarshallers.Add(nestedStructure.Name); } } } }
void GenerateUnmarshaller(List<string> structures) { foreach (var structure in structures) { var shape = this.Configuration.ServiceModel.FindShape(structure); var lookup = new NestedStructureLookup(); lookup.SearchForNestedStructures(shape); foreach (var nestedStructure in lookup.NestedStructures) { // Skip structure unmarshallers that have already been generated for the parent model if (IsShapePresentInParentModel(this.Configuration, nestedStructure.Name)) continue; if (this.Configuration.ServiceModel.Customizations.IsSubstitutedShape(nestedStructure.Name)) continue; // Skip already processed unmarshallers. This handles the case of structures being returned in mulitiple requests. if (!this._processedUnmarshallers.Contains(nestedStructure.Name)) { var generator = GetStructureUnmarshaller(); generator.Structure = nestedStructure; this.ExecuteGenerator(generator, nestedStructure.Name + "Unmarshaller.cs", "Model.Internal.MarshallTransformations"); this._processedUnmarshallers.Add(nestedStructure.Name); } } } }
/// <summary> /// Generates the request marshaller. /// </summary> /// <param name="operation">The operation to generate request marshallers for</param> void GenerateRequestMarshaller(Operation operation) { bool hasRequest = operation.RequestStructure != null; bool normalizeMarshallers; BaseRequestMarshaller generator; GetRequestMarshaller(out generator, out normalizeMarshallers); generator.Operation = operation; this.ExecuteGenerator(generator, operation.Name + "RequestMarshaller.cs", "Model.Internal.MarshallTransformations"); if (hasRequest) this.processedMarshallers.Add(operation.RequestStructure.Name); if (normalizeMarshallers && hasRequest) { var lookup = new NestedStructureLookup(); lookup.SearchForNestedStructures(operation.RequestStructure); foreach (var nestedStructure in lookup.NestedStructures) { if (!this.processedMarshallers.Contains(nestedStructure.Name)) { var structureGenerator = GetStructureMarshaller(); structureGenerator.Structure = nestedStructure; this.ExecuteGenerator(structureGenerator, nestedStructure.Name + "Marshaller.cs", "Model.Internal.MarshallTransformations"); //this.processedUnmarshallers.Add(nestedStructure.Name); } } } }