Skip to content

Commit

Permalink
Support mixed attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Ganss committed Feb 5, 2015
1 parent 12c1836 commit 2e33f09
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions XmlSchemaClassGenerator/Generator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,7 @@ private TypeModel CreateTypeModel(Uri source, XmlSchemaType type, XmlQualifiedNa
XmlSchemaType = type,
IsAbstract = complexType.IsAbstract,
IsAnonymous = type.QualifiedName.Name == "",
IsMixed = complexType.IsMixed,
EnableDataBinding = EnableDataBinding,
};

Expand Down
11 changes: 11 additions & 0 deletions XmlSchemaClassGenerator/TypeModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ public virtual CodeExpression GetDefaultValueFor(string defaultString)
public class ClassModel : TypeModel
{
public bool IsAbstract { get; set; }
public bool IsMixed { get; set; }
public TypeModel BaseClass { get; set; }
public List<PropertyModel> Properties { get; set; }
public List<ClassModel> DerivedTypes { get; set; }
Expand Down Expand Up @@ -262,6 +263,16 @@ public override CodeTypeDeclaration Generate()
foreach (var property in Properties)
property.AddMembersTo(classDeclaration, EnableDataBinding);

if (IsMixed)
{
var text = new CodeMemberField(typeof(string), "Text");
// hack to generate automatic property
text.Name += " { get; set; }";
var xmlTextAttribute = new CodeAttributeDeclaration(new CodeTypeReference(typeof(XmlTextAttribute)));
text.CustomAttributes.Add(xmlTextAttribute);
classDeclaration.Members.Add(text);
}

classDeclaration.CustomAttributes.Add(
new CodeAttributeDeclaration(new CodeTypeReference(typeof(DebuggerStepThroughAttribute))));
if (Configuration.GenerateDesignerCategoryAttribute)
Expand Down

0 comments on commit 2e33f09

Please sign in to comment.