protected override void OnTypeNameChanged(CodeTypeExtension typeExtension, string oldName, string newName) { // Prepare the XmlTypeAttribute attribute to specify the type name on the wire. CodeAttributeDeclaration xmlType = new CodeAttributeDeclaration("System.Xml.Serialization.XmlTypeAttribute", new CodeAttributeArgumentExtended("TypeName", new CodePrimitiveExpression(oldName), true)); // Add the XmlTypeAttribute attribute to ctd. typeExtension.AddAttribute(xmlType); // Do we have an XmlRootAttribute attribute? CodeAttributeDeclaration xmlRoot = typeExtension.FindAttribute("System.Xml.Serialization.XmlRootAttribute"); if (xmlRoot != null) { // Prepare the XmlRootAttribute attribute to specify the type name on the wire. xmlRoot = new CodeAttributeDeclaration("System.Xml.Serialization.XmlRootAttribute", new CodeAttributeArgumentExtended("ElementName", new CodePrimitiveExpression(oldName), true)); // Add XmlRootAttribute attribute to ctd. typeExtension.AddAttribute(xmlRoot); } }
protected override void OnTypeNameChanged(CodeTypeExtension typeExtension, string oldName, string newName) { // Prepare the MessageContractAttribute attribute to specify the type name on the wire. CodeAttributeDeclaration messageContractAttribute = typeExtension.FindAttribute("System.ServiceModel.MessageContractAttribute"); if (messageContractAttribute != null) { CodeAttributeArgument wrapperNameArgument = messageContractAttribute.Arguments .OfType <CodeAttributeArgument>() .FirstOrDefault(arg => arg.Name.Equals("WrapperName", StringComparison.OrdinalIgnoreCase)); if (wrapperNameArgument == null) { return; } CodePrimitiveExpression wrapperNameValue = wrapperNameArgument.Value as CodePrimitiveExpression; if (wrapperNameValue != null && !string.IsNullOrEmpty((string)wrapperNameValue.Value)) { string newWrapperNameValue = PascalCaseConverterHelper.GetPascalCaseName((string)wrapperNameValue.Value); wrapperNameArgument.Value = new CodePrimitiveExpression(newWrapperNameValue); } } else { CodeAttributeDeclaration xmlType = new CodeAttributeDeclaration("System.ServiceModel.MessageContractAttribute", new CodeAttributeArgumentExtended("WrapperName", new CodePrimitiveExpression(oldName), true)); // Add the XmlTypeAttribute attribute to ctd. typeExtension.AddAttribute(xmlType); } }
protected override void OnTypeNameChanged(CodeTypeExtension typeExtension, string oldName, string newName) { // Preserve Name values of XmlTypeAttribute or XmlRootAttribute here, because // the XML names can be different than the .NET class name. This occurs, for example, // when two XSD types have the same localname, but different XML namespaces. // The code generator then renames the second .NET class, while the names in XML // attributes should not be changed. // See also: http://wscfblue.codeplex.com/workitem/12733. // If [XmlTypeAttribute(TypeName="XXX")] already exists, preserve the XXX value. CodeAttributeDeclaration xmlType = typeExtension.FindAttribute("System.Xml.Serialization.XmlTypeAttribute"); if (xmlType != null) { CodeAttributeArgument typeName = xmlType.FindArgument("TypeName"); if (typeName != null) { CodePrimitiveExpression expr = (CodePrimitiveExpression)typeName.Value; oldName = expr.Value.ToString(); } } // Prepare the XmlTypeAttribute attribute to specify the type name on the wire. xmlType = new CodeAttributeDeclaration("System.Xml.Serialization.XmlTypeAttribute", new CodeAttributeArgumentExtended("TypeName", new CodePrimitiveExpression(oldName), true)); // Add/merge the XmlTypeAttribute attribute to ctd. typeExtension.AddAttribute(xmlType); // Prepare the XmlRootAttribute attribute to specify the type name on the wire. CodeAttributeDeclaration xmlRoot = new CodeAttributeDeclaration("System.Xml.Serialization.XmlRootAttribute", new CodeAttributeArgumentExtended("ElementName", new CodePrimitiveExpression(oldName), true)); // Add/merge XmlRootAttribute attribute to ctd. typeExtension.AddAttribute(xmlRoot); }
public bool IsMatching(CodeTypeExtension type) { return (type.FindAttribute("System.ServiceModel.MessageContractAttribute") != null); }
public bool IsMatching(CodeTypeExtension type) { return(type.FindAttribute("System.ServiceModel.MessageContractAttribute") != null); }
public bool IsMatching(CodeTypeExtension type) { return (type.FindAttribute("System.ServiceModel.ServiceBehaviorAttribute") != null); }
public bool IsMatching(CodeTypeExtension type) { return(type.FindAttribute("System.ServiceModel.ServiceBehaviorAttribute") != null); }
public bool IsMatching(CodeTypeExtension type) { return (type.FindAttribute("System.Xml.Serialization.XmlTypeAttribute") != null || type.FindAttribute("System.Xml.Serialization.XmlRootAttribute") != null); }
public bool IsMatching(CodeTypeExtension type) { return(type.FindAttribute("System.Xml.Serialization.XmlTypeAttribute") != null || type.FindAttribute("System.Xml.Serialization.XmlRootAttribute") != null); }
protected override void OnTypeNameChanged(CodeTypeExtension typeExtension, string oldName, string newName) { // Prepare the MessageContractAttribute attribute to specify the type name on the wire. CodeAttributeDeclaration messageContractAttribute = typeExtension.FindAttribute("System.ServiceModel.MessageContractAttribute"); if (messageContractAttribute != null) { CodeAttributeArgument wrapperNameArgument = messageContractAttribute.Arguments .OfType<CodeAttributeArgument>() .FirstOrDefault(arg => arg.Name.Equals("WrapperName", StringComparison.OrdinalIgnoreCase)); if (wrapperNameArgument == null) return; CodePrimitiveExpression wrapperNameValue = wrapperNameArgument.Value as CodePrimitiveExpression; if (wrapperNameValue != null && !string.IsNullOrEmpty((string)wrapperNameValue.Value)) { string newWrapperNameValue = PascalCaseConverterHelper.GetPascalCaseName((string)wrapperNameValue.Value); wrapperNameArgument.Value = new CodePrimitiveExpression(newWrapperNameValue); } } else { CodeAttributeDeclaration xmlType = new CodeAttributeDeclaration("System.ServiceModel.MessageContractAttribute", new CodeAttributeArgumentExtended("WrapperName", new CodePrimitiveExpression(oldName), true)); // Add the XmlTypeAttribute attribute to ctd. typeExtension.AddAttribute(xmlType); } }