本文整理汇总了C#中Project.GetItems方法的典型用法代码示例。如果您正苦于以下问题:C# Project.GetItems方法的具体用法?C# Project.GetItems怎么用?C# Project.GetItems使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Project
的用法示例。
在下文中一共展示了Project.GetItems方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestRemove_ItemNotInList
public void TestRemove_ItemNotInList()
{
var underTest = new Project();
var projectItem = new ProjectItem("p1");
underTest.AddItem(projectItem);
underTest.RemoveItem(projectItem);
var result = underTest.GetItems();
Assert.NotNull(result);
Assert.Equal(0, result.Count());
}
示例2: TestAddItem_ReturnsItemInList
public void TestAddItem_ReturnsItemInList()
{
var underTest = new Project();
var projectItem = new ProjectItem("p1");
underTest.AddItem(projectItem);
var items = underTest.GetItems();
Assert.NotNull(items);
var list = items.ToList();
Assert.Equal(1, list.Count);
Assert.Equal(projectItem, list[0]);
}
示例3: GetMapFromProject
/// <summary>
/// Gets the map from a project that matches a map path.
/// </summary>
/// <param name="project">The project in which the map resides.</param>
/// <param name="mapPath">The map path to identify the map.</param>
/// <returns>A Task representing the map.</returns>
private Task<Map> GetMapFromProject(Project project, string mapPath)
{
// Return null if either of the two parameters are invalid.
if (project == null || string.IsNullOrEmpty(mapPath))
return null;
// Get all the maps from the project and
var mapProjectItems = project.GetItems<MapProjectItem>().ToList();
// iterate through them to see if any of them match the map path provided.
foreach (MapProjectItem nextMapProjectItem in mapProjectItems)
{
if (nextMapProjectItem.Path == mapPath)
return QueuedTask.Run<Map>(() => { return nextMapProjectItem.GetMap(); }, Progressor.None);
}
// If none match, return null.
return null;
}
示例4: GetMapFromProject
/// <summary>
/// Gets the map from a project that matches a map name.
/// </summary>
/// <param name="project">The project in which the map resides.</param>
/// <param name="mapName">The map name to identify the map.</param>
/// <returns>A Task representing the map.</returns>
private Task<Map> GetMapFromProject(Project project, string mapName)
{
// Return null if either of the two parameters are invalid.
if (project == null || string.IsNullOrEmpty(mapName))
return null;
// Find the first project item with name matches with mapName
MapProjectItem mapProjItem =
project.GetItems<MapProjectItem>().FirstOrDefault(item => item.Name.Equals(mapName, StringComparison.CurrentCultureIgnoreCase));
if (mapProjItem != null)
return QueuedTask.Run<Map>(() => { return mapProjItem.GetMap(); }, Progressor.None);
else
return null;
}
示例5: Test_OneToMany_RemoveItemRemovesGeneratedItems
public void Test_OneToMany_RemoveItemRemovesGeneratedItems()
{
var kind = "test";
var project = new Project();
var p1 = AddAndCreateItem(kind, project, "p1");
var task = new Mock<IBuildTask>();
task.SetupGet(p => p.DependsOn).Returns(BuildQuery.SingleFromKind(kind));
var id1 = new ProjectItemIdentifier("created", "created");
var id2 = new ProjectItemIdentifier("created2", "created");
var s1 = new BuildTaskResult(id1, NullProjectItemContent.Instance);
var s2 = new BuildTaskResult(id2, NullProjectItemContent.Instance);
SetupProceed(task, p1).Returns(new[] { s1, s2 });
var builder = new Builder(project);
builder.AddTask(task.Object);
project.RemoveItem(p1);
var result = project.GetItems();
Assert.NotNull(result);
Assert.Empty(result);
}
示例6: TestManyToOne
public void TestManyToOne()
{
var kind = "test";
var project = new Project();
AddAndCreateItem(kind, project, "p1");
AddAndCreateItem(kind, project, "p2");
AddAndCreateItem(kind, project, "p3");
var task = new Mock<IBuildTask>();
task.SetupGet(p => p.DependsOn).Returns(BuildQuery.AllFromKind(kind));
var id = new ProjectItemIdentifier("created", "created");
task.Setup(p => p.Proceed(It.Is<IEnumerable<ProjectItem>>(list => list.SequenceEqual(project.GetItems()))))
.Returns(new [] { new BuildTaskResult(id, NullProjectItemContent.Instance) });
var builder = new Builder(project);
builder.AddTask(task.Object);
task.Verify(p => p.Proceed(It.IsAny<IEnumerable<ProjectItem>>()), Times.Once());
var result = project.GetItemById(id);
Assert.NotNull(result);
var linkedItems = result.GetLinkedItems();
Assert.NotNull(linkedItems);
var linkedItemsList = linkedItems.ToList();
Assert.Equal(3, linkedItemsList.Count);
}