public static string DetermineAWSQueryTestExpression(Member member)
{
var isEC2Protocol = member.model.IsEC2Protocol;
var testExpression = DetermineAWSQueryBaseUnmarshallName(member);
if (member.IsList)
{
if (!member.Shape.IsFlattened)
{
testExpression += "/";
if (member.Shape.ListMarshallName != null)
testExpression += member.Shape.ListMarshallName;
else
testExpression += "member";
// If the list element shape has a customization replacing it
// with another shape, extend the expression with any subexpression
// to the value member that the replaced shape has. This allows us to
// handle collections of EC2's AttributeValue shape which is replaced
// by a 'string' and we unmarshall the collection using the shape's 'value'
// member.
var listShape = member.Shape.ModelListShape;
var substituteShapeData = member.model.Customizations.GetSubstituteShapeData(listShape.Name);
if (substituteShapeData != null)
{
if (substituteShapeData[CustomizationsModel.EmitFromMemberKey] != null)
{
var valueMember = (string)substituteShapeData[CustomizationsModel.EmitFromMemberKey];
if (isEC2Protocol)
testExpression += "/" + TransformUnmarshallLocationName(true, valueMember);
else
testExpression += "/" + valueMember;
}
else
{
if (listShape.ValueMarshallName != null)
testExpression += "/" + listShape.ValueMarshallName;
}
}
}
else
{
testExpression = member.Shape.ListMarshallName;
}
}
else if (member.IsMap)
{
if (!member.Shape.IsFlattened)
testExpression += "/entry";
}
else
{
var substituteShapeData = member.model.Customizations.GetSubstituteShapeData(member.ModelShape.Name);
if (substituteShapeData != null && substituteShapeData[CustomizationsModel.EmitFromMemberKey] != null)
{
var valueMember = (string)substituteShapeData[CustomizationsModel.EmitFromMemberKey];
var subMember = member.ModelShape.Members.Single(m => m.PropertyName.Equals(valueMember, StringComparison.Ordinal));
var subExpression = string.IsNullOrEmpty(subMember.MarshallLocationName)
? subMember.MarshallName
: subMember.MarshallLocationName;
if (!string.IsNullOrEmpty(subExpression))
testExpression += "/" + subExpression;
}
}
return testExpression;
}