System.Xml.Serialization.CodeExporter.ExportConstant C# (CSharp) Method

ExportConstant() static private method

static private ExportConstant ( CodeTypeDeclaration codeClass, ConstantMapping constant, Type type, bool init, long enumValue ) : void
codeClass System.CodeDom.CodeTypeDeclaration
constant ConstantMapping
type System.Type
init bool
enumValue long
return void
        internal static void ExportConstant(CodeTypeDeclaration codeClass, ConstantMapping constant,  Type type, bool init, long enumValue) {
            CodeMemberField field = new CodeMemberField(typeof(int).FullName, constant.Name);
            field.Comments.Add(new CodeCommentStatement(Res.GetString(Res.XmlRemarks), true));
            if (init)
                field.InitExpression = new CodePrimitiveExpression(enumValue);
            codeClass.Members.Add(field);
            if (constant.XmlName != constant.Name) {
                CodeAttributeDeclaration attribute = new CodeAttributeDeclaration(type.FullName);
                attribute.Arguments.Add(new CodeAttributeArgument(new CodePrimitiveExpression(constant.XmlName)));
                field.CustomAttributes.Add(attribute);
            }
        }