Пример #1
0
        internal override XmlSchemaParticle GetOptimizedParticle(bool isTop)
        {
            if (OptimizedParticle != null)
            {
                return(OptimizedParticle);
            }
            if (Items.Count == 0 || ValidatedMaxOccurs == 0)
            {
                OptimizedParticle = XmlSchemaParticle.Empty;
                return(OptimizedParticle);
            }
            if (!isTop && ValidatedMinOccurs == 1 && ValidatedMaxOccurs == 1)
            {
                if (Items.Count == 1)
                {
                    return(((XmlSchemaParticle)Items [0]).GetOptimizedParticle(false));
                }
            }

            XmlSchemaSequence seq = new XmlSchemaSequence();

            CopyInfo(seq);
            for (int i = 0; i < Items.Count; i++)
            {
                XmlSchemaParticle p = Items [i] as XmlSchemaParticle;
                p = p.GetOptimizedParticle(false);
                if (p == XmlSchemaParticle.Empty)
                {
                    continue;
                }

                else if (p is XmlSchemaSequence && p.ValidatedMinOccurs == 1 && p.ValidatedMaxOccurs == 1)
                {
                    XmlSchemaSequence ps = p as XmlSchemaSequence;
                    for (int pi = 0; pi < ps.Items.Count; pi++)
                    {
                        seq.Items.Add(ps.Items [pi]);
                        seq.CompiledItems.Add(ps.Items [pi]);
                    }
                }
                else
                {
                    seq.Items.Add(p);
                    seq.CompiledItems.Add(p);
                }
            }
            if (seq.Items.Count == 0)
            {
                OptimizedParticle = XmlSchemaParticle.Empty;
            }
            else
            {
                OptimizedParticle = seq;
            }
            return(OptimizedParticle);
        }
Пример #2
0
        internal override XmlSchemaParticle GetOptimizedParticle(bool isTop)
        {
            if (OptimizedParticle != null)
            {
                return(OptimizedParticle);
            }

            if (Items.Count == 0 || ValidatedMaxOccurs == 0)
            {
                OptimizedParticle = XmlSchemaParticle.Empty;
            }
            // LAMESPEC: Regardless of isTop, it should remove pointless particle. It seems ContentTypeParticle design bug.
            else if (!isTop && Items.Count == 1 && ValidatedMinOccurs == 1 && ValidatedMaxOccurs == 1)
            {
                OptimizedParticle = ((XmlSchemaParticle)Items [0]).GetOptimizedParticle(false);
            }
            else
            {
                XmlSchemaChoice c = new XmlSchemaChoice();
                CopyInfo(c);
                for (int i = 0; i < Items.Count; i++)
                {
                    XmlSchemaParticle p = Items [i] as XmlSchemaParticle;
                    p = p.GetOptimizedParticle(false);
                    if (p == XmlSchemaParticle.Empty)
                    {
                        continue;
                    }
                    else if (p is XmlSchemaChoice && p.ValidatedMinOccurs == 1 && p.ValidatedMaxOccurs == 1)
                    {
                        XmlSchemaChoice pc = p as XmlSchemaChoice;
                        for (int ci = 0; ci < pc.Items.Count; ci++)
                        {
                            c.Items.Add(pc.Items [ci]);
                            c.CompiledItems.Add(pc.Items [ci]);
                        }
                    }
                    else
                    {
                        c.Items.Add(p);
                        c.CompiledItems.Add(p);
                    }
                }
                if (c.Items.Count == 0)
                {
                    OptimizedParticle = XmlSchemaParticle.Empty;
                }
                else
                {
                    OptimizedParticle = c;
                }
            }
            return(OptimizedParticle);
        }
Пример #3
0
 internal void CopyOptimizedItems(XmlSchemaGroupBase gb)
 {
     for (int i = 0; i < this.Items.Count; i++)
     {
         XmlSchemaParticle xmlSchemaParticle = this.Items[i] as XmlSchemaParticle;
         xmlSchemaParticle = xmlSchemaParticle.GetOptimizedParticle(false);
         if (xmlSchemaParticle != XmlSchemaParticle.Empty)
         {
             gb.Items.Add(xmlSchemaParticle);
             gb.CompiledItems.Add(xmlSchemaParticle);
         }
     }
 }
 internal override XmlSchemaParticle GetOptimizedParticle(bool isTop)
 {
     if (this.OptimizedParticle != null)
     {
         return(this.OptimizedParticle);
     }
     if (this.Items.Count == 0 || base.ValidatedMaxOccurs == 0m)
     {
         this.OptimizedParticle = XmlSchemaParticle.Empty;
     }
     else if (!isTop && this.Items.Count == 1 && base.ValidatedMinOccurs == 1m && base.ValidatedMaxOccurs == 1m)
     {
         this.OptimizedParticle = ((XmlSchemaParticle)this.Items[0]).GetOptimizedParticle(false);
     }
     else
     {
         XmlSchemaChoice xmlSchemaChoice = new XmlSchemaChoice();
         this.CopyInfo(xmlSchemaChoice);
         for (int i = 0; i < this.Items.Count; i++)
         {
             XmlSchemaParticle xmlSchemaParticle = this.Items[i] as XmlSchemaParticle;
             xmlSchemaParticle = xmlSchemaParticle.GetOptimizedParticle(false);
             if (xmlSchemaParticle != XmlSchemaParticle.Empty)
             {
                 if (xmlSchemaParticle is XmlSchemaChoice && xmlSchemaParticle.ValidatedMinOccurs == 1m && xmlSchemaParticle.ValidatedMaxOccurs == 1m)
                 {
                     XmlSchemaChoice xmlSchemaChoice2 = xmlSchemaParticle as XmlSchemaChoice;
                     for (int j = 0; j < xmlSchemaChoice2.Items.Count; j++)
                     {
                         xmlSchemaChoice.Items.Add(xmlSchemaChoice2.Items[j]);
                         xmlSchemaChoice.CompiledItems.Add(xmlSchemaChoice2.Items[j]);
                     }
                 }
                 else
                 {
                     xmlSchemaChoice.Items.Add(xmlSchemaParticle);
                     xmlSchemaChoice.CompiledItems.Add(xmlSchemaParticle);
                 }
             }
         }
         if (xmlSchemaChoice.Items.Count == 0)
         {
             this.OptimizedParticle = XmlSchemaParticle.Empty;
         }
         else
         {
             this.OptimizedParticle = xmlSchemaChoice;
         }
     }
     return(this.OptimizedParticle);
 }
Пример #5
0
 internal void CopyOptimizedItems(XmlSchemaGroupBase gb)
 {
     for (int i = 0; i < Items.Count; i++)
     {
         XmlSchemaParticle p = Items [i] as XmlSchemaParticle;
         p = p.GetOptimizedParticle(false);
         if (p == XmlSchemaParticle.Empty)
         {
             continue;
         }
         gb.Items.Add(p);
         gb.CompiledItems.Add(p);
     }
 }
Пример #6
0
        internal override XmlSchemaParticle GetOptimizedParticle(bool isTop)
        {
            if (OptimizedParticle != null)
            {
                return(OptimizedParticle);
            }
            if (Items.Count == 0 || ValidatedMaxOccurs == 0)
            {
                OptimizedParticle = XmlSchemaParticle.Empty;
                return(OptimizedParticle);
            }
            else if (Items.Count == 1)
            {
                if (ValidatedMinOccurs == 1 && ValidatedMaxOccurs == 1)
                {
                    XmlSchemaSequence seq = new XmlSchemaSequence();
                    this.CopyInfo(seq);
                    XmlSchemaParticle p = (XmlSchemaParticle)Items [0];
                    p = p.GetOptimizedParticle(false);
                    if (p == XmlSchemaParticle.Empty)
                    {
                        OptimizedParticle = p;
                    }
                    else
                    {
                        seq.Items.Add(p);
                        seq.CompiledItems.Add(p);
                        seq.Compile(null, schema);
                        OptimizedParticle = seq;
                    }
                    return(OptimizedParticle);
                }
            }

            XmlSchemaAll all = new XmlSchemaAll();

            CopyInfo(all);
            CopyOptimizedItems(all);
            OptimizedParticle = all;
            all.ComputeEmptiable();

            return(OptimizedParticle);
        }
Пример #7
0
        internal override XmlSchemaParticle GetOptimizedParticle(bool isTop)
        {
            if (this.OptimizedParticle != null)
            {
                return(this.OptimizedParticle);
            }
            if (this.Items.Count == 0 || base.ValidatedMaxOccurs == 0m)
            {
                this.OptimizedParticle = XmlSchemaParticle.Empty;
                return(this.OptimizedParticle);
            }
            if (this.Items.Count == 1 && base.ValidatedMinOccurs == 1m && base.ValidatedMaxOccurs == 1m)
            {
                XmlSchemaSequence xmlSchemaSequence = new XmlSchemaSequence();
                this.CopyInfo(xmlSchemaSequence);
                XmlSchemaParticle xmlSchemaParticle = (XmlSchemaParticle)this.Items[0];
                xmlSchemaParticle = xmlSchemaParticle.GetOptimizedParticle(false);
                if (xmlSchemaParticle == XmlSchemaParticle.Empty)
                {
                    this.OptimizedParticle = xmlSchemaParticle;
                }
                else
                {
                    xmlSchemaSequence.Items.Add(xmlSchemaParticle);
                    xmlSchemaSequence.CompiledItems.Add(xmlSchemaParticle);
                    xmlSchemaSequence.Compile(null, this.schema);
                    this.OptimizedParticle = xmlSchemaSequence;
                }
                return(this.OptimizedParticle);
            }
            XmlSchemaAll xmlSchemaAll = new XmlSchemaAll();

            this.CopyInfo(xmlSchemaAll);
            base.CopyOptimizedItems(xmlSchemaAll);
            this.OptimizedParticle = xmlSchemaAll;
            xmlSchemaAll.ComputeEmptiable();
            return(this.OptimizedParticle);
        }