Skip to content

Commit

Permalink
Fix #237
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Ganss committed Nov 20, 2020
1 parent d6d9419 commit 3c0b485
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions XmlSchemaClassGenerator/TypeModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -372,21 +372,29 @@ public override CodeTypeDeclaration Generate()
member.Name += " { get; set; }";
}

var docs = new[] { new DocumentationModel { Language = "en", Text = "Gets or sets the text value." },
var docs = new List<DocumentationModel> { new DocumentationModel { Language = "en", Text = "Gets or sets the text value." },
new DocumentationModel { Language = "de", Text = "Ruft den Text ab oder legt diesen fest." } };
member.Comments.AddRange(DocumentationModel.GetComments(docs).ToArray());

var attribute = new CodeAttributeDeclaration(new CodeTypeReference(typeof(XmlTextAttribute), Configuration.CodeTypeReferenceOptions));
if (BaseClass is SimpleModel simpleModel && (simpleModel.XmlSchemaType.Datatype.IsDataTypeAttributeAllowed() ?? simpleModel.UseDataTypeAttribute))

if (BaseClass is SimpleModel simpleModel)
{
var name = BaseClass.GetQualifiedName();
if (name.Namespace == XmlSchema.Namespace)
docs.AddRange(simpleModel.Restrictions.Select(r => new DocumentationModel { Language = "en", Text = r.Description }));
member.CustomAttributes.AddRange(simpleModel.GetRestrictionAttributes().ToArray());

if (simpleModel.XmlSchemaType.Datatype.IsDataTypeAttributeAllowed() ?? simpleModel.UseDataTypeAttribute)
{
var dataType = new CodeAttributeArgument("DataType", new CodePrimitiveExpression(name.Name));
attribute.Arguments.Add(dataType);
var name = BaseClass.GetQualifiedName();
if (name.Namespace == XmlSchema.Namespace)
{
var dataType = new CodeAttributeArgument("DataType", new CodePrimitiveExpression(name.Name));
attribute.Arguments.Add(dataType);
}
}
}

member.Comments.AddRange(DocumentationModel.GetComments(docs).ToArray());

member.CustomAttributes.Add(attribute);
classDeclaration.Members.Add(member);

Expand Down Expand Up @@ -551,15 +559,15 @@ public ReferenceTypeModel(GeneratorConfiguration configuration)

public List<PropertyModel> Properties { get; set; }
public List<InterfaceModel> Interfaces { get; }

public void AddInterfaces(IEnumerable<InterfaceModel> interfaces)
{
foreach (var interfaceModel in interfaces)
{
Interfaces.Add(interfaceModel);
interfaceModel.DerivedTypes.Add(this);
}

}
}

Expand Down

0 comments on commit 3c0b485

Please sign in to comment.