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


C# Project.GetItemsIgnoringCondition方法代码示例

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


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

示例1: RemoveItem_IncludingFromIgnoringConditionList

        public void RemoveItem_IncludingFromIgnoringConditionList()
        {
            XmlReader content = XmlReader.Create(new StringReader(ObjectModelHelpers.CleanupFileContents(
@"<Project ToolsVersion=""msbuilddefaulttoolsversion"" xmlns=""msbuildnamespace"">
  <ItemGroup Condition=""false"">
    <i Include=""i1"" />
  </ItemGroup>
</Project>")));

            Project project = new Project(content);

            Assert.Equal(0, Helpers.MakeList(project.GetItems("i")).Count);
            List<ProjectItem> itemsIgnoringCondition = Helpers.MakeList(project.GetItemsIgnoringCondition("i"));
            Assert.Equal(1, itemsIgnoringCondition.Count);
            ProjectItem item = itemsIgnoringCondition[0];
            Assert.Equal("i1", item.EvaluatedInclude);

            bool result = project.RemoveItem(item);

            Assert.Equal(false, result); // false as it was not in the regular items collection
            itemsIgnoringCondition = Helpers.MakeList(project.GetItemsIgnoringCondition("i"));
            Assert.Equal(0, itemsIgnoringCondition.Count);
        }
开发者ID:cdmihai,项目名称:msbuild,代码行数:23,代码来源:DefinitionEditing_Tests.cs

示例2: ProcessProjectFile

        private IEnumerable<ProcessPath> ProcessProjectFile(ProcessPath process, ScanResult result)
        {
            List<ProcessPath> newFiles = new List<ProcessPath>();

            // If this project is not processed already, read through it all.
            ScannedProject scannedProject;
            string key = ScannedProject.CalculateKey(process.Path, process.Properties);
            if (!result.ProjectFiles.TryGetValue(key, out scannedProject))
            {
                Project project = new Project(process.Path, process.Properties, null);
                string projectFolder = Path.GetDirectoryName(project.FullPath);
                string type = project.GetPropertyValue("OutputType");

                scannedProject = new ScannedProject(type, project.FullPath, process.Properties, null);
                ICollection<ProjectItem> projectReferences = project.GetItemsIgnoringCondition("ProjectReference");
                if (this.RecurseProjects && projectReferences != null)
                {
                    foreach (ProjectItem projectReference in projectReferences)
                    {
                        // TODO: process Property metadata.
                        string include = Path.Combine(projectFolder, projectReference.EvaluatedInclude);
                        newFiles.Add(new ProcessPath(include) { Project = scannedProject });
                    }
                }

                ICollection<ProjectItem> compiles = project.GetItemsIgnoringCondition("Compile");
                if (compiles != null)
                {
                    foreach (ProjectItem item in compiles)
                    {
                        // TODO: process DefineConstants property.
                        string include = Path.Combine(projectFolder, item.EvaluatedInclude);
                        newFiles.Add(new ProcessPath(include) { Project = scannedProject });
                    }
                }

                Debug.Assert(key == scannedProject.Key, String.Format("{0} should equal {1}", key, scannedProject.Key));
                result.ProjectFiles.Add(scannedProject.Key, scannedProject);
            }

            // If there is a parent project, create a reference between the two projects.
            if (process.Project != null)
            {
                process.Project.TargetProjects.Add(scannedProject);
                scannedProject.SourceProjects.Add(process.Project);
                //result.ProjectToProjectReferences.Add(new ScannedProjectProjectReference() { SourceProject = process.Project, TargetProject = scannedProject });
            }

            return newFiles;
        }
开发者ID:Jeremiahf,项目名称:wix3,代码行数:50,代码来源:Scanner.cs

示例3: ChangeItemType

        public void ChangeItemType()
        {
            Project project = new Project();
            project.AddItem("i", "i1");

            project.ReevaluateIfNecessary();

            ProjectItem item = Helpers.GetFirst(project.GetItems("i"));
            item.ItemType = "j";

            Assert.Equal("j", item.ItemType);

            string expected = ObjectModelHelpers.CleanupFileContents(
@"<Project ToolsVersion=""msbuilddefaulttoolsversion"" xmlns=""msbuildnamespace"">
  <ItemGroup>
    <j Include=""i1"" />
  </ItemGroup>
</Project>");

            Helpers.VerifyAssertProjectContent(expected, project.Xml);

            ProjectItemGroupElement itemGroupElement = Helpers.GetFirst(project.Xml.ItemGroups);
            Assert.Equal(1, Helpers.MakeList(itemGroupElement.Items).Count);
            Assert.Equal(true, Object.ReferenceEquals(itemGroupElement, item.Xml.Parent));

            Assert.Equal(1, Helpers.MakeList(project.Items).Count);
            Assert.Equal(1, Helpers.MakeList(project.ItemsIgnoringCondition).Count);

            Assert.Equal(0, Helpers.MakeList(project.GetItems("i")).Count);
            Assert.Equal(0, Helpers.MakeList(project.GetItemsIgnoringCondition("i")).Count);

            Assert.Equal(true, Object.ReferenceEquals(item, Helpers.GetFirst(project.GetItems("j"))));
            Assert.Equal(true, Object.ReferenceEquals(item, Helpers.GetFirst(project.GetItemsIgnoringCondition("j"))));
            Assert.Equal(true, Object.ReferenceEquals(item, Helpers.GetFirst(project.GetItemsByEvaluatedInclude("i1"))));
        }
开发者ID:cdmihai,项目名称:msbuild,代码行数:35,代码来源:DefinitionEditing_Tests.cs


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