开发者

Any way to check if a XmlSchemaParticle is an EmptyParticle?

I'm struggl开发者_JS百科ing 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.


I know this is old, but what if you checked if the ContentTypeParticle was not public.

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

}

I know you're specifically testing for empty, but could we go under the assumption that an internal/private object type reflects empty?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜