コード例 #1
0
        internal static bool HasParticleRef(XmlSchemaParticle particle, XmlSchema parentSchema)
        {
            XmlSchemaGroupBase groupBase = particle as XmlSchemaGroupBase;

            if (groupBase != null)
            {
                bool foundRef = false;
                int  i        = 0;
                while (i < groupBase.Items.Count && !foundRef)
                {
                    XmlSchemaParticle p = (XmlSchemaParticle)groupBase.Items[i++];
                    if (p is XmlSchemaGroupRef)
                    {
                        foundRef = true;
                    }
                    else
                    {
                        XmlSchemaElement elem = p as XmlSchemaElement;
                        // This is the same condition as in the CloneParticle method
                        //   that's on purpose. This method is used to determine if we need to clone the whole particle.
                        //   If we do, then the CloneParticle is called and it will try to clone only
                        //   those elements which need cloning - and those are the ones matching this condition.
                        if (elem != null && (!elem.RefName.IsEmpty || !elem.SchemaTypeName.IsEmpty ||
                                             GetResolvedElementForm(parentSchema, elem) == XmlSchemaForm.Qualified))
                        {
                            foundRef = true;
                        }
                        else
                        {
                            foundRef = HasParticleRef(p, parentSchema);
                        }
                    }
                }
                return(foundRef);
            }
            else if (particle is XmlSchemaGroupRef)
            {
                return(true);
            }
            return(false);
        }
コード例 #2
0
        internal static XmlSchemaParticle CloneParticle(XmlSchemaParticle particle, XmlSchema parentSchema)
        {
            XmlSchemaGroupBase groupBase = particle as XmlSchemaGroupBase;

            if (groupBase != null)
            { //Choice or sequence
                XmlSchemaGroupBase newGroupBase = groupBase;

                XmlSchemaObjectCollection newGroupbaseParticles = CloneGroupBaseParticles(groupBase.Items, parentSchema);
                newGroupBase = (XmlSchemaGroupBase)groupBase.Clone();
                newGroupBase.SetItems(newGroupbaseParticles);
                return(newGroupBase);
            }
            else if (particle is XmlSchemaGroupRef)
            { // group ref
                XmlSchemaGroupRef newGroupRef = (XmlSchemaGroupRef)particle.Clone();
                newGroupRef.RefName = newGroupRef.RefName.Clone();
                return(newGroupRef);
            }
            else
            {
                XmlSchemaElement oldElem = particle as XmlSchemaElement;
                // If the particle is an element and one of the following is true:
                //   - it references another element by name
                //   - it references its type by name
                //   - it's form (effective) is qualified (meaning it will inherint namespace from chameleon includes if that happens)
                // then the element itself needs to be cloned.
                if (oldElem != null && (!oldElem.RefName.IsEmpty || !oldElem.SchemaTypeName.IsEmpty ||
                                        GetResolvedElementForm(parentSchema, oldElem) == XmlSchemaForm.Qualified))
                {
                    XmlSchemaElement newElem = (XmlSchemaElement)oldElem.Clone(parentSchema);
                    return(newElem);
                }
            }
            return(particle);
        }
コード例 #3
0
 internal void SetParticle(XmlSchemaGroupBase value)
 {
     _particle = value;
 }