Exemple #1
0
        private void ReadItemProperty(
            VSProjectItem item, XmlReader xmlReader)
        {
            string propertyName  = xmlReader.Name;
            string propertyValue = xmlReader.ReadElementContentAsString();

            if (item.ItemProperties.ContainsKey(propertyName))
            {
                string existingPropertyValue
                    = item.ItemProperties[propertyName];

                // skip duplicate property entries
                if (Equals(propertyValue, existingPropertyValue))
                {
                    return;
                }

                string message =
                    "VS project {0} item property '{1}' already exists.".Fmt(
                        ProjectFileName, propertyName);
                throw new InvalidOperationException(message);
            }

            item.ItemProperties.Add(propertyName, propertyValue);
        }
Exemple #2
0
        private VSProjectItem ReadItem(
            XmlReader xmlReader, string itemType)
        {
            VSProjectItem item = new VSProjectItem(itemType)
            {
                Item = xmlReader["Include"]
            };

            if (!xmlReader.IsEmptyElement)
            {
                xmlReader.Read();

                while (true)
                {
                    if (xmlReader.NodeType == XmlNodeType.EndElement)
                    {
                        break;
                    }

                    ReadItemProperty(item, xmlReader);
                }
            }

            xmlReader.Read();

            return(item);
        }
Exemple #3
0
        private static void ReadItemProperty(VSProjectItem item, XmlReader xmlReader)
        {
            string propertyName  = xmlReader.Name;
            string propertyValue = xmlReader.ReadElementContentAsString();

            item.ItemProperties.Add(propertyName, propertyValue);
        }
Exemple #4
0
        private void ReadItemGroup(XmlReader xmlReader)
        {
            xmlReader.Read();

            while (xmlReader.NodeType != XmlNodeType.EndElement && !xmlReader.EOF)
            {
                switch (xmlReader.Name)
                {
                case "Content":
                    VSProjectItem contentItem = ReadItem(xmlReader, VSProjectItem.Content);
                    items.Add(contentItem);
                    break;

                case "Compile":
                    VSProjectItem compileItems = ReadItem(xmlReader, VSProjectItem.CompileItem);
                    items.Add(compileItems);
                    break;

                case "None":
                    VSProjectItem noneItem = ReadItem(xmlReader, VSProjectItem.NoneItem);
                    items.Add(noneItem);
                    break;

                case "ProjectReference":
                    VSProjectItem projectReference = ReadItem(xmlReader, VSProjectItem.ProjectReference);
                    items.Add(projectReference);
                    break;

                case "Reference":
                    VSProjectItem reference = ReadItem(xmlReader, VSProjectItem.Reference);
                    items.Add(reference);
                    break;

                default:
                    xmlReader.Skip();
                    continue;
                }
            }
        }