本文整理汇总了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);
}
示例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;
}
示例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"))));
}