diff --git a/XmlSchemaClassGenerator.Console/Program.cs b/XmlSchemaClassGenerator.Console/Program.cs
index adb5136e..d7ab27b1 100644
--- a/XmlSchemaClassGenerator.Console/Program.cs
+++ b/XmlSchemaClassGenerator.Console/Program.cs
@@ -32,6 +32,7 @@ static void Main(string[] args)
var collectionType = typeof(Collection<>);
Type collectionImplementationType = null;
var codeTypeReferenceOptions = default(CodeTypeReferenceOptions);
+ string textValuePropertyName = "Value";
var options = new OptionSet {
{ "h|help", "show this message and exit", v => showHelp = v != null },
@@ -70,7 +71,8 @@ A file name may be given by appending a pipe sign (|) followed by a file name (l
{ "a|pascal", "use Pascal case for class and property names (default is enabled)", v => pascal = v != null },
{ "ct|collectionType=", "collection type to use (default is " + typeof(Collection<>).FullName + ")", v => collectionType = v == null ? typeof(Collection<>) : Type.GetType(v, true) },
{ "cit|collectionImplementationType=", "the default collection type implementation to use (default is null)", v => collectionImplementationType = v == null ? null : Type.GetType(v, true) },
- { "ctro|codeTypeReferenceOptions=", "the default CodeTypeReferenceOptions Flags to use (default is unset; can be: {GlobalReference, GenericTypeParameter})", v => codeTypeReferenceOptions = v == null ? default(CodeTypeReferenceOptions) : (CodeTypeReferenceOptions)Enum.Parse(typeof(CodeTypeReferenceOptions), v, false) }
+ { "ctro|codeTypeReferenceOptions=", "the default CodeTypeReferenceOptions Flags to use (default is unset; can be: {GlobalReference, GenericTypeParameter})", v => codeTypeReferenceOptions = v == null ? default(CodeTypeReferenceOptions) : (CodeTypeReferenceOptions)Enum.Parse(typeof(CodeTypeReferenceOptions), v, false) },
+ { "tvpn|textValuePropertyName=", "the name of the property that holds the text value of an element (default is Value)", v => textValuePropertyName = v }
};
var files = options.Parse(args);
@@ -110,7 +112,8 @@ A file name may be given by appending a pipe sign (|) followed by a file name (l
NamingScheme = pascal ? NamingScheme.PascalCase : NamingScheme.Direct,
CollectionType = collectionType,
CollectionImplementationType = collectionImplementationType,
- CodeTypeReferenceOptions = codeTypeReferenceOptions
+ CodeTypeReferenceOptions = codeTypeReferenceOptions,
+ TextValuePropertyName = textValuePropertyName
};
if (pclCompatible)
diff --git a/XmlSchemaClassGenerator/Generator.cs b/XmlSchemaClassGenerator/Generator.cs
index 7c531ad7..b8f5807a 100644
--- a/XmlSchemaClassGenerator/Generator.cs
+++ b/XmlSchemaClassGenerator/Generator.cs
@@ -145,6 +145,12 @@ public CodeTypeReferenceOptions CodeTypeReferenceOptions
set { _configuration.CodeTypeReferenceOptions = value; }
}
+ public string TextValuePropertyName
+ {
+ get { return _configuration.TextValuePropertyName; }
+ set { _configuration.TextValuePropertyName = value; }
+ }
+
///
/// Optional delegate that is called for each generated type member
///
diff --git a/XmlSchemaClassGenerator/GeneratorConfiguration.cs b/XmlSchemaClassGenerator/GeneratorConfiguration.cs
index 8c9a38a7..abf55c49 100644
--- a/XmlSchemaClassGenerator/GeneratorConfiguration.cs
+++ b/XmlSchemaClassGenerator/GeneratorConfiguration.cs
@@ -115,6 +115,11 @@ public GeneratorConfiguration()
///
public CodeTypeReferenceOptions CodeTypeReferenceOptions { get; set; }
+ ///
+ /// The name of the property that will contain the text value of an XML element
+ ///
+ public string TextValuePropertyName { get; set; } = "Value";
+
///
/// Provides a fast and safe way to write to the Log
///
diff --git a/XmlSchemaClassGenerator/TypeModel.cs b/XmlSchemaClassGenerator/TypeModel.cs
index aab6dc35..f842388e 100644
--- a/XmlSchemaClassGenerator/TypeModel.cs
+++ b/XmlSchemaClassGenerator/TypeModel.cs
@@ -275,11 +275,11 @@ public override CodeTypeDeclaration Generate()
{
classDeclaration.BaseTypes.Add(BaseClass.GetReferenceFor(Namespace, false));
}
- else
+ else if (!string.IsNullOrEmpty(Configuration.TextValuePropertyName))
{
var typeReference = BaseClass.GetReferenceFor(Namespace, false);
- var member = new CodeMemberField(typeReference, "Value")
+ var member = new CodeMemberField(typeReference, Configuration.TextValuePropertyName)
{
Attributes = MemberAttributes.Public,
};