Any way to check if the XmlSchemaParticle is an empty page?

I'm struggling with something, is there a way to check if the XmlSchemaParticle EmptyParticle or not?

XmlSchemaParticle.EmptyParticle seems to be a private inner class of the XmlSchemaParticle .

What I'm doing right now is particle.GetType().Name == "EmptyParticle" and I find it pretty ugly.

Any other option?

+6
c # xml xsd
source share
4 answers
+1
source share

I think you should consider that ContentTypeParticle with MaxOccurs == 0 empty.

+1
source share

Today I have faced the same problem. I managed to get around this by setting the XmlSchemaComplexType.ContentType property:

 public bool HasEmptyParticle(XmlSchemaComplexType type) { return type.ContentTypeParticle != null && type.ContentType == XmlSchemaContentType.Empty; } 
+1
source share

I know this is old, but what if you checked to see if the ContentTypeParticle is public.

If (! Type.ContentTypeParticle.GetType (). IsPublic) {

}

I know that you specifically test empty, but can we assume that the internal / private type of the object reflects empty?

0
source share

All Articles