void AddElementMetadata(CodeAttributeDeclarationCollection metadata, string elementName, TypeDesc typeDesc, bool isNullable) {
CodeAttributeDeclaration attribute = new CodeAttributeDeclaration(typeof(SoapElementAttribute).FullName);
if (elementName != null) {
attribute.Arguments.Add(new CodeAttributeArgument(new CodePrimitiveExpression(elementName)));
}
if (typeDesc != null && typeDesc.IsAmbiguousDataType) {
attribute.Arguments.Add(new CodeAttributeArgument("DataType", new CodePrimitiveExpression(typeDesc.DataType.Name)));
}
if (isNullable) {
attribute.Arguments.Add(new CodeAttributeArgument("IsNullable", new CodePrimitiveExpression(true)));
}
metadata.Add(attribute);
}