Ejemplo n.º 1
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;
        }
Ejemplo n.º 2
0
        internal SchemaTypeData(int openxmlTypeId, AttributeConstraint[] attributeConstraints)
        {
            this.OpenXmlTypeId = openxmlTypeId;
            // Use ReadOnlyCollection<T> as the return type in debug version.
#if DEBUG
            if (attributeConstraints != null)
            {
                this.AttributeConstraints = Array.AsReadOnly(attributeConstraints);
            }
#else
            this.AttributeConstraints = attributeConstraints;
#endif
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Load the attribute constraints and simple type constraint for attributes for the schema type.
        /// </summary>
        /// <param name="sdbSchemaTpye"></param>
        /// <returns></returns>
        private AttributeConstraint[] BuildAttributeConstraint(SdbSchemaType sdbSchemaTpye)
        {
            Debug.Assert(sdbSchemaTpye != null);
            if (sdbSchemaTpye.AttributesCount > 0)
            {
                int count = sdbSchemaTpye.AttributesCount;
                var attributeConstraints = new AttributeConstraint[count];

                SdbIndex sdbIndex = sdbSchemaTpye.StartIndexOfAttributes;
                for (int i = 0; i < count; i++)
                {
                    var sdbAttributeData = this.SdbAttributes[sdbIndex + i];
                    // then load the simple type constraint for this attribute
                    var simpleTypeIndex      = sdbAttributeData.SimpleTypeIndex;
                    var simpleTypeConstraint = this.SimpleTypeRestrictions[simpleTypeIndex];
                    attributeConstraints[i] = new AttributeConstraint(sdbAttributeData.AttributeUse, simpleTypeConstraint, (FileFormatVersions)(sdbAttributeData.FileFormatVersion));
                }
                return(attributeConstraints);
            }

            return(null);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the SchemaTypeData.
 /// </summary>
 /// <param name="openxmlTypeId"></param>
 /// <param name="attributeConstraints"></param>
 /// <param name="simpleTypeConstraint"></param>
 /// <remarks>
 /// For simple type or complex type which is simple content (no particle children).
 /// </remarks>
 internal SchemaTypeData(int openxmlTypeId, AttributeConstraint[] attributeConstraints, SimpleTypeRestriction simpleTypeConstraint)
     : this(openxmlTypeId, attributeConstraints)
 {
     Debug.Assert(simpleTypeConstraint != null);
     this.SimpleTypeConstraint = simpleTypeConstraint;
 }