diff --git a/XmlSchemaClassGenerator/IXmlSchemaNode.cs b/XmlSchemaClassGenerator/IXmlSchemaNode.cs index 12eda4da..d25e69d7 100644 --- a/XmlSchemaClassGenerator/IXmlSchemaNode.cs +++ b/XmlSchemaClassGenerator/IXmlSchemaNode.cs @@ -5,15 +5,15 @@ namespace XmlSchemaClassGenerator { public interface IXmlSchemaNode { - string Name { get; } + //string Name { get; } string DefaultValue { get; } string FixedValue { get; } XmlSchemaForm Form { get; } XmlQualifiedName QualifiedName { get; } XmlQualifiedName RefName { get; } - XmlSchemaType SchemaType { get; } - XmlSchemaType NodeSchemaType { get; } - XmlQualifiedName SchemaTypeName { get; } + //XmlQualifiedName SchemaTypeName { get; } + //XmlSchemaType SchemaType { get; } + //XmlSchemaType NodeSchemaType { get; } XmlSchemaAnnotated Base { get; } XmlSchemaForm FormDefault { get; } @@ -25,23 +25,23 @@ public sealed class XmlSchemaAttributeEx : IXmlSchemaNode public XmlSchemaAttribute Real { get; } - public string Name => Real.Name; + //public string Name => Real.Name; public string DefaultValue => Real.DefaultValue; public string FixedValue => Real.FixedValue; public XmlSchemaForm Form => Real.Form; public XmlQualifiedName QualifiedName => Real.QualifiedName; public XmlQualifiedName RefName => Real.RefName; - public XmlQualifiedName SchemaTypeName => Real.SchemaTypeName; - public XmlSchemaSimpleType SchemaType => Real.SchemaType; + //public XmlQualifiedName SchemaTypeName => Real.SchemaTypeName; + //public XmlSchemaSimpleType SchemaType => Real.SchemaType; public XmlSchemaSimpleType AttributeSchemaType => Real.AttributeSchemaType; public XmlSchemaAnnotated Base => Real; public XmlSchemaForm FormDefault => Base.GetSchema().AttributeFormDefault; - XmlSchemaType IXmlSchemaNode.SchemaType => SchemaType; + //XmlSchemaType IXmlSchemaNode.SchemaType => SchemaType; - XmlSchemaType IXmlSchemaNode.NodeSchemaType => AttributeSchemaType; + //XmlSchemaType IXmlSchemaNode.NodeSchemaType => AttributeSchemaType; public XmlSchemaUse Use => Real.Use; @@ -55,23 +55,23 @@ public sealed class XmlSchemaElementEx : IXmlSchemaNode public XmlSchemaElement Real { get; } - public string Name => Real.Name; + //public string Name => Real.Name; public string DefaultValue => Real.DefaultValue; public string FixedValue => Real.FixedValue; public XmlSchemaForm Form => Real.Form; public XmlQualifiedName QualifiedName => Real.QualifiedName; public XmlQualifiedName RefName => Real.RefName; - public XmlQualifiedName SchemaTypeName => Real.SchemaTypeName; - public XmlSchemaType SchemaType => Real.SchemaType; + //public XmlQualifiedName SchemaTypeName => Real.SchemaTypeName; + //public XmlSchemaType SchemaType => Real.SchemaType; public XmlSchemaType ElementSchemaType => Real.ElementSchemaType; public XmlSchemaAnnotated Base => Real; public XmlSchemaForm FormDefault => Base.GetSchema().ElementFormDefault; - XmlSchemaType IXmlSchemaNode.SchemaType => SchemaType; + //XmlSchemaType IXmlSchemaNode.SchemaType => SchemaType; - XmlSchemaType IXmlSchemaNode.NodeSchemaType => ElementSchemaType; + //XmlSchemaType IXmlSchemaNode.NodeSchemaType => ElementSchemaType; public bool IsNillable => Real.IsNillable; diff --git a/XmlSchemaClassGenerator/ModelBuilder.cs b/XmlSchemaClassGenerator/ModelBuilder.cs index 2bc1cce1..1aaabae4 100644 --- a/XmlSchemaClassGenerator/ModelBuilder.cs +++ b/XmlSchemaClassGenerator/ModelBuilder.cs @@ -755,9 +755,9 @@ private IEnumerable CreatePropertiesForAttributes(Uri source, Typ foreach (var item in items) { - if (item is XmlSchemaAttribute node) + if (item is XmlSchemaAttribute xs) { - XmlSchemaAttributeEx attribute = node; + XmlSchemaAttributeEx attribute = xs; if (attribute.Use != XmlSchemaUse.Prohibited) { var attributeQualifiedName = attribute.AttributeSchemaType.QualifiedName; @@ -806,10 +806,10 @@ private IEnumerable CreatePropertiesForAttributes(Uri source, Typ var property = new PropertyModel(_configuration, name, typeModel, owningTypeModel) { IsAttribute = true, - IsRequired = node.Use == XmlSchemaUse.Required + IsRequired = attribute.Use == XmlSchemaUse.Required }; - property.SetFromNode(originalName, () => node.Use != XmlSchemaUse.Optional, attribute); + property.SetFromNode(originalName, () => attribute.Use != XmlSchemaUse.Optional, attribute); property.SetSchemaNameAndNamespace(owningTypeModel, attribute); property.Documentation.AddRange(GetDocumentation(attribute)); @@ -865,7 +865,7 @@ private IEnumerable CreatePropertiesForElements(Uri source, TypeM if (item.XmlParticle is XmlSchemaElement xs && xs.ElementSchemaType != null) { XmlSchemaElementEx element = xs; - XmlSchemaElementEx effectiveElement = substitute?.Element ?? xs; + XmlSchemaElementEx effectiveElement = substitute?.Element ?? element; var name = _configuration.NamingProvider.ElementNameFromQualifiedName(effectiveElement.QualifiedName, effectiveElement); var originalName = name; if (name == owningTypeModel.Name) @@ -873,9 +873,9 @@ private IEnumerable CreatePropertiesForElements(Uri source, TypeM name = owningTypeModel.GetUniquePropertyName(name); - var typeModel = substitute?.Type ?? CreateTypeModel(GetQualifiedName(owningTypeModel, xmlParticle, xs), xs.ElementSchemaType); + var typeModel = substitute?.Type ?? CreateTypeModel(GetQualifiedName(owningTypeModel, xmlParticle, element), element.ElementSchemaType); - property = new PropertyModel(_configuration, name, typeModel, owningTypeModel) { IsNillable = xs.IsNillable }; + property = new PropertyModel(_configuration, name, typeModel, owningTypeModel) { IsNillable = element.IsNillable }; property.SetFromParticles(particle, item); property.SetFromNode(originalName, () => item.MinOccurs >= 1.0m && item.XmlParent is not XmlSchemaChoice, element); property.SetSchemaNameAndNamespace(owningTypeModel, effectiveElement);