protected override void OnFieldNameChanged(CodeTypeMemberExtension memberExtension, string oldName, string newName)
{
// Field can be either a body member or a message header.
// First see if the field is a body member.
CodeAttributeDeclaration bodyMember = memberExtension.FindAttribute("System.ServiceModel.MessageBodyMemberAttribute");
// If this is a body member, modify the MessageBodyMemberAttribute to include the wire name.
if (bodyMember != null)
{
CodeAttributeDeclaration newBodyMember =
new CodeAttributeDeclaration("System.ServiceModel.MessageBodyMemberAttribute",
new CodeAttributeArgumentExtended("Name",
new CodePrimitiveExpression(oldName), true));
memberExtension.AddAttribute(newBodyMember);
}
// Now check whether the field is a message header.
CodeAttributeDeclaration header = memberExtension.FindAttribute("System.ServiceModel.MessageHeaderAttribute");
if (header != null)
{
CodeAttributeDeclaration newHeader =
new CodeAttributeDeclaration("System.ServiceModel.MessageHeaderAttribute",
new CodeAttributeArgumentExtended("Name",
new CodePrimitiveExpression(oldName), true));
memberExtension.AddAttribute(newHeader);
}
// Make sure the field name change is reflected in the field name references.
ConvertFieldReferencesInConstructors(memberExtension.Parent.Constructors, oldName, newName);
}