示例#1
0
        public void SaveToXml(XmlElement nodeProject, string basePath)
        {
            XmlDocument xmldoc = nodeProject.OwnerDocument;

            foreach (ItemGroup group in dicGroups.Values)
            {
                if (group.Count < 1)
                {
                    continue;
                }

                XmlElement elemGroup = xmldoc.CreateElement("ItemGroup", Consts.NamesapceURI);
                foreach (NodeBase item in group)
                {
                    if (item.GetType() == typeof(PublishFileItem))
                    {
                        PublishFileItem publishFile = (PublishFileItem)item;
                        //if (publishFile.IsDefault)//是默认值,则无需发布属性
                        //    continue;
                    }

                    XmlElement elem = item.ToXml(xmldoc, basePath);
                    elemGroup.AppendChild(elem);
                }

                nodeProject.AppendChild(elemGroup);
            }
            if (itemGroupOthers.Count > 0)
            {
                XmlElement elemOthers = xmldoc.CreateElement("ItemGroup", Consts.NamesapceURI);
                foreach (XmlNode node in itemGroupOthers)
                {
                    elemOthers.AppendChild(xmldoc.ImportNode(node, true));
                }
                nodeProject.AppendChild(elemOthers);
            }
        }
示例#2
0
        public static NodeBase Create(XmlElement elem, XmlNamespaceManager nsmgr, string basePath)
        {
            if (elem == null)
            {
                return(null);
            }

            NodeBase item = null;

            switch (elem.Name)
            {
            case "Reference": item = new ReferenceItem(); break;

            case "BootstrapperPackage": item = new BootstrapperPackageItem(); break;

            case "Compile": item = new CompileItem(); break;

            case "EmbeddedResource": item = new EmbeddedResourceItem(); break;

            case "ProjectReference": item = new ProjectReferenceItem(); break;

            case "None": item = new NoneItem(); break;

            case "Content": item = new ContentItem(); break;

            case "PublishFile": item = new PublishFileItem(); break;

            default: item = null; break;
            }
            if (item != null)
            {
                item.FromXmlInternal(elem, nsmgr, basePath);
            }

            return(item);
        }