Skip to content

Commit 2d2aecf

Browse files
authored
Merge pull request #97 from canton7/feature/fixed-value
Expose XmlSchemaAttribute.FixedValue
2 parents 746e7b6 + 1baf016 commit 2d2aecf

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

XmlSchemaClassGenerator/ModelBuilder.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,7 @@ private IEnumerable<PropertyModel> CreatePropertiesForAttributes(Uri source, Typ
448448
IsAttribute = true,
449449
IsNullable = attribute.Use != XmlSchemaUse.Required,
450450
DefaultValue = attribute.DefaultValue ?? (attribute.Use != XmlSchemaUse.Optional ? attribute.FixedValue : null),
451+
FixedValue = attribute.FixedValue,
451452
Form = attribute.Form == XmlSchemaForm.None ? attribute.GetSchema().AttributeFormDefault : attribute.Form,
452453
XmlNamespace = attribute.QualifiedName.Namespace != "" && attribute.QualifiedName.Namespace != typeModel.XmlSchemaName.Namespace ? attribute.QualifiedName.Namespace : null,
453454
};
@@ -522,6 +523,7 @@ private IEnumerable<PropertyModel> CreatePropertiesForElements(Uri source, TypeM
522523
IsNullable = item.MinOccurs < 1.0m || (item.XmlParent is XmlSchemaChoice),
523524
IsCollection = item.MaxOccurs > 1.0m || particle.MaxOccurs > 1.0m, // http://msdn.microsoft.com/en-us/library/vstudio/d3hx2s7e(v=vs.100).aspx
524525
DefaultValue = element.DefaultValue ?? ((item.MinOccurs >= 1.0m && !(item.XmlParent is XmlSchemaChoice)) ? element.FixedValue : null),
526+
FixedValue = element.FixedValue,
525527
Form = element.Form == XmlSchemaForm.None ? element.GetSchema().ElementFormDefault : element.Form,
526528
XmlNamespace = element.QualifiedName.Namespace != "" && element.QualifiedName.Namespace != typeModel.XmlSchemaName.Namespace ? element.QualifiedName.Namespace : null,
527529
XmlParticle = item.XmlParticle,

XmlSchemaClassGenerator/TypeModel.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,7 @@ public class PropertyModel
499499
public bool IsNillable { get; set; }
500500
public bool IsCollection { get; set; }
501501
public string DefaultValue { get; set; }
502+
public string FixedValue { get; set; }
502503
public XmlSchemaForm Form { get; set; }
503504
public string XmlNamespace { get; set; }
504505
public List<DocumentationModel> Documentation { get; private set; }

0 commit comments

Comments
 (0)