/// <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); 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(); } }
/// <summary> /// Initializes a new instance of the SchemaTypeData. /// </summary> /// <param name="openxmlTypeId"></param> /// <param name="particleConstraint"></param> /// <remarks> /// For complex type which contains children particles. /// </remarks> public SchemaTypeData(int openxmlTypeId, ParticleConstraint particleConstraint) { Debug.Assert(particleConstraint != null); OpenXmlTypeId = openxmlTypeId; 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> /// 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(ushort particleIndex) { Debug.Assert(particleIndex >= 0); Debug.Assert(particleIndex < Particles.Length); SdbParticleConstraint sdbParticleConstraint = Particles[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 (ushort i = 0; i < sdbParticleConstraint.ChildrenCount; i++) { ushort childIndex = ParticleIndexes[(ushort)(sdbParticleConstraint.ChildrenStartIndex + i)].ParticleIndex; particleConstraint.ChildrenParticles[i] = BuildParticleConstraint(childIndex); } } else if (sdbParticleConstraint.ParticleType == ParticleType.All || sdbParticleConstraint.ParticleType == ParticleType.Choice || sdbParticleConstraint.ParticleType == ParticleType.Group || sdbParticleConstraint.ParticleType == ParticleType.Sequence) { particleConstraint.ChildrenParticles = Cached.Array <ParticleConstraint>(); } return(particleConstraint); }
/// <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 < SdbDataHead.ParticleCount); SdbParticleConstraint sdbParticleConstraint = 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 = SdbParticleIndexs[(SdbIndex)(sdbParticleConstraint.ChildrenStartIndex + i)].ParticleIndex; particleConstraint.ChildrenParticles[i] = 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; }