/// <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); }