System.Xml.Serialization.SoapCodeExporter.AddElementMetadata C# (CSharp) Method

AddElementMetadata() public method

public AddElementMetadata ( CodeAttributeDeclarationCollection metadata, string elementName, TypeDesc typeDesc, bool isNullable ) : void
metadata System.CodeDom.CodeAttributeDeclarationCollection
elementName string
typeDesc TypeDesc
isNullable bool
return void
        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);
        }