예제 #1
0
        public void AddItemNode(XmlNode aRootNode, ItemDefinitionContainer aItemContainer)
        {
            XmlNode lNode = aRootNode.OwnerDocument.CreateNode("element", "xs:element", "");

            aRootNode.AppendChild(lNode);
            AddAttribute(lNode, "name", aItemContainer.MSBuildItem.PropertyName);
            AddAttribute(lNode, "substitutionGroup", "msb:Item");
            AddAnnotationNode(lNode, aItemContainer.MSBuildItem.Description);
            AddExtensionNodes(lNode, aItemContainer);
        }
예제 #2
0
        public void GetMSBuildProperties(object[] aAssemblyAttributes, PropertyDefinitionList aPropertyList, ItemDefinitionList aItemList)
        {
            if (aPropertyList == null)
            {
                throw new ArgumentNullException("PropertyList parameter is null");
            }
            if (aItemList == null)
            {
                throw new ArgumentNullException("ItemList parameter is null");
            }
            if (aAssemblyAttributes == null)
            {
                return;
            }
            Dictionary <string, ItemDefinitionContainer> lItemContainerDictionary = new Dictionary <string, ItemDefinitionContainer>();
            List <ItemMetadataDefinitionAttribute>       lItemMetadataList        = new List <ItemMetadataDefinitionAttribute>();

            foreach (object lObj in aAssemblyAttributes)
            {
                PropertyDefinitionAttribute     lProperty     = lObj as PropertyDefinitionAttribute;
                ItemDefinitionAttribute         lItem         = lObj as ItemDefinitionAttribute;
                ItemMetadataDefinitionAttribute lItemMetadata = lObj as ItemMetadataDefinitionAttribute;
                if (lProperty != null)
                {
                    aPropertyList.Add(lProperty);
                }
                if (lItem != null)
                {
                    ItemDefinitionContainer lContainer = new ItemDefinitionContainer(lItem);
                    aItemList.Add(lContainer);
                    lItemContainerDictionary.Add(lItem.PropertyName, lContainer);
                }
                if (lItemMetadata != null)
                {
                    lItemMetadataList.Add(lItemMetadata);
                }
            }
            // now add all the meta data with the ItemGroup
            foreach (ItemMetadataDefinitionAttribute lItemMetadata in lItemMetadataList)
            {
                if (lItemContainerDictionary.ContainsKey(lItemMetadata.PropertyName))
                {
                    lItemContainerDictionary[lItemMetadata.PropertyName].ItemMetadataDefinitionList.Add(lItemMetadata);
                }
            }
        }
예제 #3
0
        private void AddExtensionNodes(XmlNode aMSBuildNode, ItemDefinitionContainer aItemContainer)
        {
            if (aItemContainer.ItemMetadataDefinitionList.Count == 0)
            {
                return;
            }
            // Create each node and append tem as follows
            //   <xs:complexType>
            //     <xs:complexContent>
            //       <xs:extension base="msb:SimpleItemType">
            //         <xs:sequence minOccurs=0 maxOccurs="unbounded">
            //           <xs:choice>
            XmlNode lComplexType    = aMSBuildNode.OwnerDocument.CreateNode("element", "xs:complexType", "");
            XmlNode lComplexContent = aMSBuildNode.OwnerDocument.CreateNode("element", "xs:complexContent", "");
            XmlNode lExtension      = aMSBuildNode.OwnerDocument.CreateNode("element", "xs:extension", "");
            XmlNode lSequence       = aMSBuildNode.OwnerDocument.CreateNode("element", "xs:sequence", "");
            XmlNode lChoice         = aMSBuildNode.OwnerDocument.CreateNode("element", "xs:choice", "");

            aMSBuildNode.AppendChild(lComplexType);
            lComplexType.AppendChild(lComplexContent);
            lComplexContent.AppendChild(lExtension);
            lExtension.AppendChild(lSequence);
            lSequence.AppendChild(lChoice);
            AddAttribute(lExtension, "base", "msb:SimpleItemType");
            AddAttribute(lSequence, "minOccurs", "0");
            AddAttribute(lSequence, "maxOccurs", "unbounded");
            // Build the meta data elements
            //   <xs:element name="MyMetadata" type="xs:string"/>
            foreach (ItemMetadataDefinitionAttribute lMetadata in aItemContainer.ItemMetadataDefinitionList)
            {
                AddChoiceElement(lChoice, lMetadata);
            }
            // Add the include documentation if need.
            if (!String.IsNullOrEmpty(aItemContainer.MSBuildItem.IncludeDescription))
            {
                AddIncludeAnnotation(lSequence, aItemContainer.MSBuildItem.IncludeDescription);
            }
        }