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();
}
}
}
}