本文整理汇总了C#中Microsoft.Build.Evaluation.Project.GetItemsByEvaluatedInclude方法的典型用法代码示例。如果您正苦于以下问题:C# Project.GetItemsByEvaluatedInclude方法的具体用法?C# Project.GetItemsByEvaluatedInclude怎么用?C# Project.GetItemsByEvaluatedInclude使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Build.Evaluation.Project
的用法示例。
在下文中一共展示了Project.GetItemsByEvaluatedInclude方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ItemsByEvaluatedIncludeDirectRemove
public void ItemsByEvaluatedIncludeDirectRemove()
{
Project project = new Project();
ProjectItem item1 = project.AddItem("i", "i1;j1")[0];
project.RemoveItem(item1);
List<ProjectItem> items = Helpers.MakeList(project.GetItemsByEvaluatedInclude("i1"));
Assert.Equal(0, items.Count);
}
示例2: ItemsByEvaluatedIncludeReevaluation
public void ItemsByEvaluatedIncludeReevaluation()
{
Project project = new Project();
project.Xml.AddItem("i", "i1");
project.ReevaluateIfNecessary();
List<ProjectItem> items = Helpers.MakeList(project.GetItemsByEvaluatedInclude("i1"));
Assert.Equal(1, items.Count);
project.Xml.AddItem("j", "i1");
project.ReevaluateIfNecessary();
items = Helpers.MakeList(project.GetItemsByEvaluatedInclude("i1"));
Assert.Equal(2, items.Count);
}
示例3: ItemsByEvaluatedIncludeDirectAdd
public void ItemsByEvaluatedIncludeDirectAdd()
{
Project project = new Project();
project.AddItem("i", "i1");
List<ProjectItem> items = Helpers.MakeList(project.GetItemsByEvaluatedInclude("i1"));
Assert.Equal(1, items.Count);
}
示例4: ItemsByEvaluatedInclude_EvaluatedIncludeNeedsEscaping
public void ItemsByEvaluatedInclude_EvaluatedIncludeNeedsEscaping()
{
Project project = new Project();
project.Xml.AddItem("i", "i%261");
project.Xml.AddItem("j", "i%25261");
project.Xml.AddItem("k", "j1");
project.Xml.AddItem("l", "i&1");
project.ReevaluateIfNecessary();
List<ProjectItem> items = Helpers.MakeList(project.GetItemsByEvaluatedInclude("i&1"));
Assert.Equal(2, items.Count);
foreach (ProjectItem item in items)
{
Assert.Equal("i&1", item.EvaluatedInclude);
Assert.True(
String.Equals(item.ItemType, "i", StringComparison.OrdinalIgnoreCase) ||
String.Equals(item.ItemType, "l", StringComparison.OrdinalIgnoreCase)
);
}
}
示例5: ItemsByEvaluatedInclude
public void ItemsByEvaluatedInclude()
{
Project project = new Project();
project.Xml.AddItem("i", "i1");
project.Xml.AddItem("i", "i1");
project.Xml.AddItem("j", "j1");
project.Xml.AddItem("j", "i1");
project.ReevaluateIfNecessary();
List<ProjectItem> items = Helpers.MakeList(project.GetItemsByEvaluatedInclude("i1"));
Assert.Equal(3, items.Count);
foreach (ProjectItem item in items)
{
Assert.Equal("i1", item.EvaluatedInclude);
}
}
示例6: 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"))));
}
示例7: RenameItemInProjectWithWildcards
public void RenameItemInProjectWithWildcards()
{
string projectDirectory = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
Directory.CreateDirectory(projectDirectory);
try
{
string sourceFile = Path.Combine(projectDirectory, "a.cs");
string renamedSourceFile = Path.Combine(projectDirectory, "b.cs");
File.Create(sourceFile).Dispose();
var project = new Project();
project.AddItem("File", "*.cs");
project.FullPath = Path.Combine(projectDirectory, "test.proj"); // assign a path so the wildcards can lock onto something.
project.ReevaluateIfNecessary();
var projectItem = project.Items.Single();
Assert.Equal(Path.GetFileName(sourceFile), projectItem.EvaluatedInclude);
Assert.Same(projectItem, project.GetItemsByEvaluatedInclude(projectItem.EvaluatedInclude).Single());
projectItem.Rename(Path.GetFileName(renamedSourceFile));
File.Move(sourceFile, renamedSourceFile); // repro w/ or w/o this
project.ReevaluateIfNecessary();
projectItem = project.Items.Single();
Assert.Equal(Path.GetFileName(renamedSourceFile), projectItem.EvaluatedInclude);
Assert.Same(projectItem, project.GetItemsByEvaluatedInclude(projectItem.EvaluatedInclude).Single());
}
finally
{
Directory.Delete(projectDirectory, recursive: true);
}
}
示例8: AddProjectReferences
public void AddProjectReferences()
{
var projects = GetProjects();
var thisProject = projects.FirstOrDefault(c => c.GuidString == "{7AAC4FDB-1C6A-453F-8126-D2E89BC1B6D9}");
var generatorTestProject =
projects.FirstOrDefault(c => c.GuidString == "{D30AC162-B004-4946-96EC-13A760A2D8FA}");
if (thisProject == null)
throw new Exception("Cannot find Generator Project, operation failed.");
projects = projects.Except(new[] { thisProject, generatorTestProject }).ToList();
var gen = new Project(thisProject.AbsolutePath);
foreach (var project in projects)
{
if (!gen.GetItemsByEvaluatedInclude(project.PathToSolution).Any())
{
gen.AddItem("ProjectReference", project.PathToSolution,
new List<KeyValuePair<string, string>>
{
new KeyValuePair<string, string>("Project", project.GuidString),
new KeyValuePair<string, string>("Name", project.Name)
});
}
}
gen.Save();
ProjectCollection.GlobalProjectCollection.UnloadAllProjects();
}