I'm struggling with something here, is there a proper way to check whether a XmlSchemaParticle
is an EmptyParticle
or not?
XmlSchemaParticle.EmptyParticle
seems to be a private inner class of XmlSchemaParticle
.
What I'm doing right now is particle.GetType().Name == "EmptyParticle"
and I find it rather ugly.
Any other option?
I ran into same problem today. I was able to get around it by checking XmlSchemaComplexType.ContentType property:
public bool HasEmptyParticle(XmlSchemaComplexType type)
{
return type.ContentTypeParticle != null && type.ContentType == XmlSchemaContentType.Empty;
}
I'd tried the same solution as you, but it's messy alright. Just about to try: http://www.c-sharpcorner.com/Forums/Thread/54685/detecting-xmlschemacomplextype-contentparticletype-is-equal.aspx
I think that you should consider any ContentTypeParticle with MaxOccurs == 0
to be empty.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With