private static void ReadItemProperty(VSProjectItem item, XmlReader xmlReader)
        {
            string propertyName  = xmlReader.Name;
            string propertyValue = xmlReader.ReadElementContentAsString();

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

            if (xmlReader.IsEmptyElement == false)
            {
                xmlReader.Read();

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

                    ReadItemProperty(projectName, item, xmlReader);
                }
            }

            xmlReader.Read();

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

            if (item.ItemProperties.ContainsKey(propertyName))
            {
                throw new ArgumentException($"Item {propertyName}:{propertyValue} already exists in project {projectName}");
            }

            item.ItemProperties.Add(propertyName, propertyValue);
        }
        private static void ReadItemProperty(string projectName, VSProjectItem item, XmlReader xmlReader)
        {
            string propertyName  = xmlReader.Name;
            string propertyValue = xmlReader.ReadElementContentAsString();

            if (item.ItemProperties.ContainsKey(propertyName))
            {
                item.ItemProperties[propertyName] = propertyValue;
                Console.WriteLine($"Item {propertyName}:{propertyValue} already exists in project {projectName}");
            }
            else
            {
                item.ItemProperties.Add(propertyName, propertyValue);
            }
        }
        private void ReadItemGroup(string projectName, XmlReader xmlReader)
        {
            xmlReader.Read();

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

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

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

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

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

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