Beispiel #1
0
        internal static ParticleValidator CreateParticleValidator(ParticleConstraint particleConstraint)
        {
            var compositeParticle = particleConstraint as CompositeParticle;

            switch (particleConstraint.ParticleType)
            {
            case ParticleType.All:
                return(new AllParticleValidator(compositeParticle));

            case ParticleType.Choice:
                return(new ChoiceParticleValidator(compositeParticle));

            case ParticleType.Sequence:
                return(new SequenceParticleValidator(compositeParticle));

            case ParticleType.Group:
                return(new GroupParticleValidator(compositeParticle));

            //case ParticleType.Any:
            //    return new AnyParticleValidator(particleConstraint);

            case ParticleType.Element:
            default:
                throw new InvalidOperationException();
            }
        }
Beispiel #2
0
        /// <summary>
        /// Initializes a new instance of the SchemaTypeData.
        /// </summary>
        /// <param name="openxmlTypeId"></param>
        /// <param name="attributeConstraints"></param>
        /// <param name="particleConstraint"></param>
        /// <remarks>
        /// For complex type which contains children particles.
        /// </remarks>
        internal SchemaTypeData(int openxmlTypeId, AttributeConstraint[] attributeConstraints, ParticleConstraint particleConstraint)
            : this(openxmlTypeId, attributeConstraints)
        {
            Debug.Assert(particleConstraint != null);

            this.ParticleConstraint = particleConstraint;
        }
Beispiel #3
0
            internal static void Validate(ValidationContext validationContext, ParticleConstraint particleConstraint)
            {
                switch (particleConstraint.ParticleType)
                {
                case ParticleType.All:
                case ParticleType.Choice:
                case ParticleType.Sequence:
                case ParticleType.Group:
                    ParticleValidator particleValidator = (ParticleValidator)particleConstraint.ParticleValidator;
                    particleValidator.Validate(validationContext);
                    break;

                case ParticleType.Invalid:
                case ParticleType.Element:
                case ParticleType.Any:
                default:
                    Debug.Assert(false);
                    break;
                }
            }
Beispiel #4
0
        /// <summary>
        /// Load the particle constraint from the specified data in binary database.
        /// </summary>
        /// <param name="particleIndex">The index of the particle constraint data in the binary database.</param>
        /// <returns>The particle constraint in ParticleConstraint.</returns>
        private ParticleConstraint BuildParticleConstraint(SdbIndex particleIndex)
        {
            Debug.Assert(particleIndex >= 0);
            Debug.Assert(particleIndex < this.SdbDataHead.ParticleCount);

            SdbParticleConstraint sdbParticleConstraint = this.SdbParticles[particleIndex];
            var particleConstraint = ParticleConstraint.CreateParticleConstraint(sdbParticleConstraint.ParticleType);

            particleConstraint.ParticleType = sdbParticleConstraint.ParticleType;
            particleConstraint.MaxOccurs    = sdbParticleConstraint.MaxOccurs;
            particleConstraint.MinOccurs    = sdbParticleConstraint.MinOccurs;
            particleConstraint.ElementId    = sdbParticleConstraint.ElementTypeId;

            if (sdbParticleConstraint.ChildrenCount > 0)
            {
                Debug.Assert(sdbParticleConstraint.ParticleType == ParticleType.All ||
                             sdbParticleConstraint.ParticleType == ParticleType.Choice ||
                             sdbParticleConstraint.ParticleType == ParticleType.Group ||
                             sdbParticleConstraint.ParticleType == ParticleType.Sequence);
                particleConstraint.ChildrenParticles = new ParticleConstraint[sdbParticleConstraint.ChildrenCount];
                for (SdbIndex i = 0; i < sdbParticleConstraint.ChildrenCount; i++)
                {
                    SdbIndex childIndex = this.SdbParticleIndexs[(SdbIndex)(sdbParticleConstraint.ChildrenStartIndex + i)].ParticleIndex;
                    particleConstraint.ChildrenParticles[i] = this.BuildParticleConstraint(childIndex);
                }
            }
            else if (sdbParticleConstraint.ParticleType == ParticleType.All ||
                     sdbParticleConstraint.ParticleType == ParticleType.Choice ||
                     sdbParticleConstraint.ParticleType == ParticleType.Group ||
                     sdbParticleConstraint.ParticleType == ParticleType.Sequence)
            {
                particleConstraint.ChildrenParticles = EmptyChildrenParticles;
            }

            return(particleConstraint);
        }
 /// <summary>
 /// Initializes a new instance of the CompositeParticleValidator.
 /// </summary>
 /// <param name="particleConstraint"></param>
 internal CompositeParticleValidator(ParticleConstraint particleConstraint)
 {
     this._particleConstraint = particleConstraint;
 }
        /// <summary>
        /// Initializes a new instance of the SchemaTypeData.
        /// </summary>
        /// <param name="openxmlTypeId"></param>
        /// <param name="attributeConstraints"></param>
        /// <param name="particleConstraint"></param>
        /// <remarks>
        /// For complex type which contains children particles.
        /// </remarks>
        internal SchemaTypeData(int openxmlTypeId, AttributeConstraint[] attributeConstraints, ParticleConstraint particleConstraint)
            : this(openxmlTypeId, attributeConstraints)
        {
            Debug.Assert(particleConstraint != null);

            this.ParticleConstraint = particleConstraint;
        }
            internal static void Validate(ValidationContext validationContext, ParticleConstraint particleConstraint)
            {
                switch (particleConstraint.ParticleType)
                {
                    case ParticleType.All:
                    case ParticleType.Choice:
                    case ParticleType.Sequence:
                    case ParticleType.Group:
                        ParticleValidator particleValidator = (ParticleValidator)particleConstraint.ParticleValidator;
                        particleValidator.Validate(validationContext);
                        break;

                    case ParticleType.Invalid:
                    case ParticleType.Element:
                    case ParticleType.Any:
                    default:
                        Debug.Assert(false);
                        break;
                }
            }
 /// <summary>
 /// Initializes a new instance of the CompositeParticleValidator.
 /// </summary>
 /// <param name="particleConstraint"></param>
 internal CompositeParticleValidator(ParticleConstraint particleConstraint)
 {
     this._particleConstraint = particleConstraint;
 }
        internal static ParticleValidator CreateParticleValidator(ParticleConstraint particleConstraint)
        {
            var compositeParticle = particleConstraint as CompositeParticle;

            switch (particleConstraint.ParticleType)
            {
                case ParticleType.All:
                    return new AllParticleValidator(compositeParticle);

                case ParticleType.Choice:
                    return new ChoiceParticleValidator(compositeParticle);

                case ParticleType.Sequence:
                    return new SequenceParticleValidator(compositeParticle);

                case ParticleType.Group:
                    return new GroupParticleValidator(compositeParticle);

                //case ParticleType.Any:
                //    return new AnyParticleValidator(particleConstraint);

                case ParticleType.Element:
                default:
                    throw new InvalidOperationException();
            }
        }