当前位置: 首页>>代码示例>>C#>>正文


C# System.Xml.XmlDocument.CreateVSItemGroup方法代码示例

本文整理汇总了C#中System.Xml.XmlDocument.CreateVSItemGroup方法的典型用法代码示例。如果您正苦于以下问题:C# System.Xml.XmlDocument.CreateVSItemGroup方法的具体用法?C# System.Xml.XmlDocument.CreateVSItemGroup怎么用?C# System.Xml.XmlDocument.CreateVSItemGroup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Xml.XmlDocument的用法示例。


在下文中一共展示了System.Xml.XmlDocument.CreateVSItemGroup方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Serialize

        Serialize()
        {
            var document = new System.Xml.XmlDocument();

            var projectEl = this.CreateRootProject(document);
            projectEl.SetAttribute("ToolsVersion", "4.0"); // TODO: get this number from VisualC

            var filtersEl = document.CreateVSItemGroup(parentEl: projectEl);

            foreach (var filter in this.Filters)
            {
                var filterEl = document.CreateVSElement("Filter", parentEl: filtersEl);
                filterEl.SetAttribute("Include", filter.Key);
                document.CreateVSElement("UniqueIdentifier", new DeterministicGuid("VSFilter" + filter.Key).Guid.ToString("B").ToUpper(), parentEl: filterEl);

                var filesEl = document.CreateVSItemGroup(parentEl: projectEl);
                var extensions = new Bam.Core.StringArray();
                foreach (var setting in filter.Value)
                {
                    var path = setting.Include;
                    var extension = System.IO.Path.GetExtension(path.Parse()).TrimStart(new[] { '.' });
                    extensions.AddUnique(extension);
                    setting.Serialize(document, filesEl);
                }
                if (extensions.Count > 0)
                {
                    document.CreateVSElement("Extensions", extensions.ToString(';'), parentEl: filterEl);
                }
            }
            return document;
        }
开发者ID:knocte,项目名称:BuildAMation,代码行数:31,代码来源:VSProjectFilter.cs

示例2: Serialize

        Serialize()
        {
            var document = new System.Xml.XmlDocument();

            var projectEl = this.CreateRootProject(document);
            projectEl.SetAttribute("DefaultTargets", "Build");
            projectEl.SetAttribute("ToolsVersion", "12.0"); // TODO: get from VisualC package

            // define configurations in the project
            var configurationItemGroup = document.CreateVSItemGroup("ProjectConfigurations", projectEl);
            foreach (var config in this.Configurations)
            {
                var projectConfigEl = document.CreateVSElement("ProjectConfiguration", parentEl: configurationItemGroup);
                projectConfigEl.SetAttribute("Include", config.Value.FullName);
                document.CreateVSElement("Configuration", value: config.Value.ConfigurationName, parentEl: projectConfigEl);
                document.CreateVSElement("Platform", value: config.Value.PlatformName, parentEl: projectConfigEl);
            }

            // global properties
            var globalPropertyGroup = document.CreateVSPropertyGroup(label: "Globals", parentEl: projectEl);
            document.CreateVSElement("ProjectGuid", value: this.Guid.ToString("B").ToUpper(), parentEl: globalPropertyGroup);

            document.CreateVSImport(@"$(VCTargetsPath)\Microsoft.Cpp.Default.props", parentEl: projectEl);

            // configuration properties
            foreach (var config in this.Configurations)
            {
                config.Value.SerializeProperties(document, projectEl);
            }

            document.CreateVSImport(@"$(VCTargetsPath)\Microsoft.Cpp.props", parentEl: projectEl);

            // configuration paths
            foreach (var config in this.Configurations)
            {
                config.Value.SerializePaths(document, projectEl);
            }

            // tool settings
            foreach (var config in this.Configurations)
            {
                config.Value.SerializeSettings(document, projectEl);
            }

            // input files (these are VSSettingsGroups, but configuration agnostic)
            if (this.Sources.Count > 0)
            {
                var sourcesGroup = document.CreateVSItemGroup(parentEl: projectEl);
                foreach (var group in this.Sources)
                {
                    foreach (var config in this.Configurations)
                    {
                        if (!config.Value.ContainsSource(group))
                        {
                            group.AddSetting("ExcludedFromBuild", "true", config.Value.ConditionText);
                        }
                    }
                    group.Serialize(document, sourcesGroup);
                }
            }
            if (this.Headers.Count > 0)
            {
                var headersGroup = document.CreateVSItemGroup(parentEl: projectEl);
                foreach (var group in this.Headers)
                {
                    group.Serialize(document, headersGroup);
                }
            }
            if (this.Others.Count > 0)
            {
                var otherGroup = document.CreateVSItemGroup(parentEl: projectEl);
                foreach (var group in this.Others)
                {
                    group.Serialize(document, otherGroup);
                }
            }
            if (this.Resources.Count > 0)
            {
                var resourceGroup = document.CreateVSItemGroup(parentEl: projectEl);
                foreach (var group in this.Resources)
                {
                    group.Serialize(document, resourceGroup);
                }
            }

            // dependent projects
            this.SerializeDependentProjects(document, projectEl);

            document.CreateVSImport(@"$(VCTargetsPath)\Microsoft.Cpp.targets", parentEl: projectEl);

            return document;
        }
开发者ID:knocte,项目名称:BuildAMation,代码行数:92,代码来源:VSProject.cs


注:本文中的System.Xml.XmlDocument.CreateVSItemGroup方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。