internal AllParticleValidator(CompositeParticle particleConstraint)
            : base(particleConstraint)
        {
            Debug.Assert(particleConstraint is not null);
            Debug.Assert(particleConstraint.ParticleType == ParticleType.All);

            // xsd:all can only contain xsd:element children and maxOccurs of each children can only be 1
#if DEBUG
            foreach (var constraint in particleConstraint.ChildrenParticles)
            {
                Debug.Assert(constraint.ParticleType == ParticleType.Element);

                // all children elements' maxOccurs must be 1
                Debug.Assert(constraint.MaxOccurs == 1);
            }
#endif

            _childrenParticles = new Dictionary <Type, bool>(ParticleConstraint.ChildrenParticles.Length);

            foreach (var childParticle in ParticleConstraint.ChildrenParticles)
            {
                if (childParticle is ElementParticle element)
                {
                    _childrenParticles.Add(element.ElementType, false);
                }
            }
        }
Пример #2
0
        public override ParticleConstraint Build(FileFormatVersions version)
        {
            if (!version.AtLeast(Version))
            {
                return(null);
            }

            // We can potentially limit creation of a clone to times when it is required; ie, when there
            // is a version specific particle.
            var clone = new CompositeParticle(ParticleType, MinOccurs, MaxOccurs, requireFilter: RequireFilter, filterVersion: true, Version);

            foreach (var child in ChildrenParticles)
            {
                clone.Add(child.Build(version));
            }

            return(clone);
        }
Пример #3
0
 protected CompositeParticleValidator(CompositeParticle particleConstraint)
 {
     ParticleConstraint = particleConstraint;
 }
 /// <summary>
 /// Initializes a new instance of the ChoiceParticleValidator.
 /// </summary>
 /// <param name="particleConstraint"></param>
 internal GroupParticleValidator(CompositeParticle particleConstraint)
     : base(particleConstraint)
 {
     Debug.Assert(particleConstraint.ParticleType == ParticleType.Group);
 }
 /// <summary>
 /// Initializes a new instance of the ChoiceParticleValidator.
 /// </summary>
 /// <param name="particleConstraint"></param>
 internal ChoiceParticleValidator(CompositeParticle particleConstraint)
     : base(particleConstraint)
 {
     Debug.Assert(particleConstraint != null);
     Debug.Assert(particleConstraint.ParticleType == ParticleType.Choice);
 }
 /// <summary>
 /// Initializes a new instance of the SequenceParticleValidator.
 /// </summary>
 /// <param name="particleConstraint"></param>
 internal SequenceParticleValidator(CompositeParticle particleConstraint)
     : base(particleConstraint)
 {
     Debug.Assert(particleConstraint.ParticleType == ParticleType.Sequence);
 }