Ejemplo n.º 1
0
        /// <summary>
        /// Try to map one Attribute to Attribute specifications.
        /// </summary>
        /// <param name="attribute">The actual Attribute to map.</param>
        /// <param name="sortedAttributeListSpecification">The Attribute specifications to map to.</param>
        /// <returns>
        /// Indicates if the supplied actual Attribute and it's direct and indirect
        /// Attribute childs have been mapped.
        /// </returns>
        public static bool Map(Attribute attribute, SortedAttributeListSpecification sortedAttributeListSpecification)
        {
            bool attributesMapped = true;

            //
            // Determine which attribute specification instances have the same tag and level.
            //

            AttributeData attributeData = new AttributeData();

            attribute.Data = attributeData;

            attributeData.Mapping = sortedAttributeListSpecification.GetAttributes(attribute.Tag.GroupNumber, attribute.Tag.ElementNumber);

            if (attributeData.Mapping.Count == 0)
            {
                attributesMapped = false;
            }

            //
            // If this attribute is a Sequence Attribute, also map its children.
            //

            if (attribute is SequenceAttribute)
            {
                SequenceAttribute sequenceAttribute = attribute as SequenceAttribute;

                SortedAttributeListSpecification sequenceItemSpecification = GetSequenceItemSpecification(attributeData.Mapping);

                foreach (SequenceItem sequenceItem in sequenceAttribute.SequenceItems)
                {
                    bool sequenceItemMapped = Map(sequenceItem, sequenceItemSpecification);

                    attributesMapped = (attributesMapped && sequenceItemMapped);
                }
            }

            attributeData.AttributesMapped = attributesMapped;

            return (attributesMapped);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Try to map one Attribute to Attribute specifications.
        /// </summary>
        /// <param name="attribute">The actual Attribute to map.</param>
        /// <param name="sortedAttributeListSpecification">The Attribute specifications to map to.</param>
        /// <returns>
        /// Indicates if the supplied actual Attribute and it's direct and indirect
        /// Attribute childs have been mapped.
        /// </returns>
        public static bool Map(Attribute attribute, SortedAttributeListSpecification sortedAttributeListSpecification)
        {
            bool attributesMapped = true;

            //
            // Determine which attribute specification instances have the same tag and level.
            //

            AttributeData attributeData = new AttributeData();

            attribute.Data = attributeData;

            attributeData.Mapping = sortedAttributeListSpecification.GetAttributes(attribute.Tag.GroupNumber, attribute.Tag.ElementNumber);

            if (attributeData.Mapping.Count == 0)
            {
                attributesMapped = false;
            }

            //
            // If this attribute is a Sequence Attribute, also map its children.
            //

            if (attribute is SequenceAttribute)
            {
                SequenceAttribute sequenceAttribute = attribute as SequenceAttribute;

                SortedAttributeListSpecification sequenceItemSpecification = GetSequenceItemSpecification(attributeData.Mapping);

                foreach (SequenceItem sequenceItem in sequenceAttribute.SequenceItems)
                {
                    bool sequenceItemMapped = Map(sequenceItem, sequenceItemSpecification);

                    attributesMapped = (attributesMapped && sequenceItemMapped);
                }
            }

            attributeData.AttributesMapped = attributesMapped;

            return(attributesMapped);
        }