本文整理汇总了C#中Microsoft.Build.Evaluation.Project.AddItemFast方法的典型用法代码示例。如果您正苦于以下问题:C# Project.AddItemFast方法的具体用法?C# Project.AddItemFast怎么用?C# Project.AddItemFast使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Build.Evaluation.Project
的用法示例。
在下文中一共展示了Project.AddItemFast方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Cleanup
private static void Cleanup(Project project, string itemTypeToCleanup)
{
var items = project.Items.Where(x => x.ItemType == itemTypeToCleanup).ToList();
project.RemoveItems(items);
var sortedItems = items.OrderBy(x => x.UnevaluatedInclude);
foreach (var item in sortedItems)
project.AddItemFast(itemTypeToCleanup, item.UnevaluatedInclude);
}
示例2: AddItemFast_MatchesWildcardInSemicolonList
public void AddItemFast_MatchesWildcardInSemicolonList()
{
Project project = new Project();
project.Xml.AddItem("i", "a;*.xxx;b");
project.ReevaluateIfNecessary();
project.AddItemFast("i", "i1.xxx");
string expected = ObjectModelHelpers.CleanupFileContents(
@"<Project ToolsVersion=""msbuilddefaulttoolsversion"" xmlns=""msbuildnamespace"">
<ItemGroup>
<i Include=""a;*.xxx;b"" />
</ItemGroup>
</Project>");
Helpers.VerifyAssertProjectContent(expected, project);
}
示例3: AddItemFastWithMetadata_DoesNotMatchWildcardWithNoMetadata
public void AddItemFastWithMetadata_DoesNotMatchWildcardWithNoMetadata()
{
Project project = new Project();
ProjectItemElement item1 = project.Xml.AddItem("i", "*.xxx");
project.ReevaluateIfNecessary();
Dictionary<string, string> metadata = new Dictionary<string, string>() { { "m", "m1" } };
ProjectItemElement item2 = project.AddItemFast("i", "i1.xxx", metadata)[0].Xml;
string expected = ObjectModelHelpers.CleanupFileContents(
@"<Project ToolsVersion=""msbuilddefaulttoolsversion"" xmlns=""msbuildnamespace"">
<ItemGroup>
<i Include=""*.xxx"" />
<i Include=""i1.xxx"">
<m>m1</m>
</i>
</ItemGroup>
</Project>");
Helpers.VerifyAssertProjectContent(expected, project);
}
示例4: AddItemFast_DoesntMatchComplicatedWildcard
public void AddItemFast_DoesntMatchComplicatedWildcard()
{
Project project = new Project();
ProjectItemElement item1 = project.Xml.AddItem("i", @"c:\subdir1\**\subdir2\**\*.x?x");
project.ReevaluateIfNecessary();
ProjectItemElement item2 = project.AddItemFast("i", @"c:\subdir1\a\b\c\i1.xyx")[0].Xml;
string expected = ObjectModelHelpers.CleanupFileContents(
@"<Project ToolsVersion=""msbuilddefaulttoolsversion"" xmlns=""msbuildnamespace"">
<ItemGroup>
<i Include=""c:\subdir1\**\subdir2\**\*.x?x"" />
<i Include=""c:\subdir1\a\b\c\i1.xyx"" />
</ItemGroup>
</Project>");
Helpers.VerifyAssertProjectContent(expected, project);
Assert.Equal(false, Object.ReferenceEquals(item1, item2));
}
示例5: AddItemFast_MatchesWildcardWithExclude
public void AddItemFast_MatchesWildcardWithExclude()
{
Project project = new Project();
ProjectItemElement itemElement = project.Xml.AddItem("i", "*.xxx");
itemElement.Exclude = "i2.xxx";
project.ReevaluateIfNecessary();
project.AddItemFast("i", "i1.xxx");
string expected = ObjectModelHelpers.CleanupFileContents(
@"<Project ToolsVersion=""msbuilddefaulttoolsversion"" xmlns=""msbuildnamespace"">
<ItemGroup>
<i Include=""*.xxx"" Exclude=""i2.xxx"" />
<i Include=""i1.xxx"" />
</ItemGroup>
</Project>");
Helpers.VerifyAssertProjectContent(expected, project);
}
示例6: AddItemFast_ContainingWildcardNoMatches
public void AddItemFast_ContainingWildcardNoMatches()
{
Project project = new Project();
IList<ProjectItem> items = project.AddItemFast("i", @"c:\" + Guid.NewGuid().ToString() + @"\**\i1");
Assert.Equal(0, items.Count);
}
示例7: AddItemFast_IncludeContainsItemExpression
public void AddItemFast_IncludeContainsItemExpression()
{
Project project = new Project();
project.AddItemFast("h", "h1");
project.ReevaluateIfNecessary();
ProjectItem item = project.AddItemFast("i", "@(h)")[0];
Assert.Equal("@(h)", item.UnevaluatedInclude);
Assert.Equal("h1", item.EvaluatedInclude);
}
示例8: AddItemFast_IncludeContainsWildcard
public void AddItemFast_IncludeContainsWildcard()
{
string[] paths = null;
try
{
paths = Helpers.CreateFiles("i1.xxx", "i2.xxx");
string wildcard = Path.Combine(Path.GetDirectoryName(paths[0]), "*.xxx;");
Project project = new Project();
project.AddItemFast("i", wildcard);
string expected = String.Format
(
ObjectModelHelpers.CleanupFileContents(
@"<Project ToolsVersion=""msbuilddefaulttoolsversion"" xmlns=""msbuildnamespace"">
<ItemGroup>
<i Include=""{0}"" />
</ItemGroup>
</Project>"
),
wildcard
);
List<ProjectItem> items = Helpers.MakeList(project.Items);
Assert.Equal(2, items.Count);
Assert.Equal(paths[0], items[0].EvaluatedInclude);
Assert.Equal(paths[1], items[1].EvaluatedInclude);
}
finally
{
Helpers.DeleteFiles(paths);
}
}
示例9: AddItemFast_IncludeContainsPropertyExpression
public void AddItemFast_IncludeContainsPropertyExpression()
{
Project project = new Project();
project.SetProperty("p", "v1");
project.ReevaluateIfNecessary();
project.AddItemFast("i", "$(p)");
Assert.Equal("$(p)", Helpers.GetFirst(project.Items).UnevaluatedInclude);
Assert.Equal("v1", Helpers.GetFirst(project.Items).EvaluatedInclude);
}
示例10: AddItemFast_NullMetadata
public void AddItemFast_NullMetadata()
{
Project project = new Project();
project.AddItemFast("i", "i1", null);
string expected = ObjectModelHelpers.CleanupFileContents(
@"<Project ToolsVersion=""msbuilddefaulttoolsversion"" xmlns=""msbuildnamespace"">
<ItemGroup>
<i Include=""i1"" />
</ItemGroup>
</Project>");
Helpers.VerifyAssertProjectContent(expected, project.Xml);
}
示例11: AddItemFast_InvalidEmptyInclude
public void AddItemFast_InvalidEmptyInclude()
{
Assert.Throws<ArgumentException>(() =>
{
Project project = new Project();
project.AddItemFast("i", String.Empty);
}
);
}
示例12: AddItemFast_WithMetadata
public void AddItemFast_WithMetadata()
{
Project project = new Project();
List<KeyValuePair<string, string>> metadata = new List<KeyValuePair<string, string>>();
metadata.Add(new KeyValuePair<string, string>("m", "m1"));
project.AddItemFast("i", "i1", metadata);
string expected = ObjectModelHelpers.CleanupFileContents(
@"<Project ToolsVersion=""msbuilddefaulttoolsversion"" xmlns=""msbuildnamespace"">
<ItemGroup>
<i Include=""i1"">
<m>m1</m>
</i>
</ItemGroup>
</Project>");
Helpers.VerifyAssertProjectContent(expected, project.Xml);
}
示例13: AddItemFast_EscapedItemInclude
public void AddItemFast_EscapedItemInclude()
{
Project project = new Project();
project.AddItemFast("i", "i%281%29");
string expected = ObjectModelHelpers.CleanupFileContents(
@"<Project ToolsVersion=""msbuilddefaulttoolsversion"" xmlns=""msbuildnamespace"">
<ItemGroup>
<i Include=""i%281%29"" />
</ItemGroup>
</Project>");
Helpers.VerifyAssertProjectContent(expected, project.Xml);
List<ProjectItem> items = Helpers.MakeList(project.Items);
Assert.Equal(1, items.Count);
Assert.Equal("i", items[0].ItemType);
Assert.Equal("i(1)", items[0].EvaluatedInclude);
Assert.Equal("i(1)", Helpers.GetFirst(project.GetItems("i")).EvaluatedInclude);
Assert.Equal("i(1)", Helpers.MakeList(project.CreateProjectInstance().GetItems("i"))[0].EvaluatedInclude);
}
示例14: AddItemFast_MatchesWildcard
public void AddItemFast_MatchesWildcard()
{
Project project = new Project();
ProjectItemElement item1 = project.Xml.AddItem("i", "*.xxx");
project.ReevaluateIfNecessary();
ProjectItemElement item2 = project.AddItemFast("i", "i1.xxx")[0].Xml;
string expected = ObjectModelHelpers.CleanupFileContents(
@"<Project ToolsVersion=""msbuilddefaulttoolsversion"" xmlns=""msbuildnamespace"">
<ItemGroup>
<i Include=""*.xxx"" />
</ItemGroup>
</Project>");
Helpers.VerifyAssertProjectContent(expected, project);
Assert.AreEqual(true, Object.ReferenceEquals(item1, item2));
}
示例15: AddItemFast_InvalidEmptyInclude
public void AddItemFast_InvalidEmptyInclude()
{
Project project = new Project();
project.AddItemFast("i", String.Empty);
}