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


C# BuildItem.GetMetadata方法代码示例

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


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

示例1: ProjectRef

		public ProjectRef(BuildItem item, TranslatePath fnTranslate)
		{
			this.RefType = String.Format("{0}", Check.NotNull(item).Name);
			if (item.GetMetadata("Private") == "True")
				CopyLocal = true;
			if (item.GetMetadata("SpecificVersion") == "True")
				SpecificVersion = true;
			if (!String.IsNullOrEmpty(item.Condition))
				this.Condition = item.Condition;
			if (RefType == "ProjectReference")
				this.FromProjectReference(item, Check.NotNull(fnTranslate));
			else if (RefType == "Reference")
				this.FromFileReference(item, Check.NotNull(fnTranslate));
			else
				throw new ApplicationException("Unkown reference type " + RefType);
		}
开发者ID:hivie7510,项目名称:csharptest-net,代码行数:16,代码来源:ProjectRef.cs

示例2: SetMetadataSimple

        public void SetMetadataSimple()
        {
            BuildItem item = new BuildItem("n", "i");
            item.SetMetadata("m", "v");

            Assertion.AssertEquals(true, item.HasMetadata("m"));
            Assertion.AssertEquals("v", item.GetMetadata("m"));
        }
开发者ID:nikson,项目名称:msbuild,代码行数:8,代码来源:BuildItem_Tests.cs

示例3: TestSetMetadata3

		public void TestSetMetadata3 ()
		{
			item = new BuildItem ("name", "include");
			item.SetMetadata ("a", "$(A)");
			item.SetMetadata ("b", "$(A)", true);
			item.SetMetadata ("c", "$(A)", false);

			Assert.AreEqual ("$(A)", item.GetEvaluatedMetadata ("a"), "A1");
			Assert.AreEqual ("$(A)", item.GetEvaluatedMetadata ("b"), "A2");
			Assert.AreEqual ("$(A)", item.GetEvaluatedMetadata ("c"), "A3");
			Assert.AreEqual ("$(A)", item.GetMetadata ("a"), "A4");
			Assert.AreEqual (Utilities.Escape ("$(A)"), item.GetMetadata ("b"), "A5");
			Assert.AreEqual ("$(A)", item.GetMetadata ("c"), "A6");
		}
开发者ID:GirlD,项目名称:mono,代码行数:14,代码来源:BuildItemTest.cs

示例4: TestGetMetadata2

		public void TestGetMetadata2 ()
		{
			item = new BuildItem ("name", "spec");
			item.GetMetadata (null);
		}
开发者ID:GirlD,项目名称:mono,代码行数:5,代码来源:BuildItemTest.cs

示例5: TestGetMetadata1

		public void TestGetMetadata1 ()
		{
			string itemName = "a";
			string itemInclude = "a;b;c";
			string metadataName = "name";
			string metadataValue = "a;b;c";

			item = new BuildItem (itemName, itemInclude);

			Assert.AreEqual (String.Empty, item.GetMetadata (metadataName), "A1");

			item.SetMetadata (metadataName, metadataValue);

			Assert.AreEqual (metadataValue, item.GetMetadata (metadataName), "A2");
			Assert.IsTrue (item.GetMetadata ("FullPath").EndsWith (Utilities.Escape (itemInclude)), "A3");
			//Assert.IsTrue (String.Empty != item.GetMetadata ("RootDir"), "A4");
			Assert.AreEqual (itemInclude, item.GetMetadata ("Filename"), "A5");
			Assert.AreEqual (String.Empty, item.GetMetadata ("Extension"), "A6");
			Assert.AreEqual (String.Empty, item.GetMetadata ("RelativeDir"), "A7");
			Assert.IsTrue (String.Empty != item.GetMetadata ("Directory"), "A8");
			Assert.AreEqual (String.Empty, item.GetMetadata ("RecursiveDir"), "A9");
			Assert.AreEqual (itemInclude, item.GetMetadata ("Identity"), "A10");
			// FIXME: test with CreatedTime
			Assert.AreEqual (String.Empty, item.GetMetadata ("ModifiedTime"), "A11");
			Assert.AreEqual (String.Empty, item.GetMetadata ("ModifiedTime"), "A12");
			Assert.AreEqual (String.Empty, item.GetMetadata ("AccessedTime"), "A13");
		}
开发者ID:GirlD,项目名称:mono,代码行数:27,代码来源:BuildItemTest.cs

示例6: TestCopyCustomMetadataTo1

		public void TestCopyCustomMetadataTo1 ()
		{
			BuildItem source, destination;
			string itemName1 = "a";
			string itemName2 = "b";
			string itemInclude = "a;b;c";
			string metadataName = "name";
			string metadataValue = "value";

			source = new BuildItem (itemName1, itemInclude);
			destination = new BuildItem (itemName2, itemInclude);

			source.SetMetadata (metadataName, metadataValue);

			source.CopyCustomMetadataTo (destination);

			Assert.AreEqual (metadataValue, destination.GetMetadata (metadataName), "A1");
			Assert.AreEqual (metadataValue, destination.GetEvaluatedMetadata (metadataName), "A2");
		}
开发者ID:GirlD,项目名称:mono,代码行数:19,代码来源:BuildItemTest.cs

示例7: CheckBuildItem

		static void CheckBuildItem (BuildItem item, string name, string [,] metadata, string finalItemSpec, string prefix)
		{
			Assert.AreEqual (name, item.Name, prefix + "#1");
			for (int i = 0; i < metadata.GetLength (0); i++) {
				string key = metadata [i, 0];
				string val = metadata [i, 1];
				Assert.IsTrue (item.HasMetadata (key), String.Format ("{0}#2: Expected metadata '{1}' not found", prefix, key));
				Assert.AreEqual (val, item.GetMetadata (key), String.Format ("{0}#3: Value for metadata {1}", prefix, key));
				Assert.AreEqual (val, item.GetEvaluatedMetadata (key), String.Format ("{0}#4: Value for evaluated metadata {1}", prefix, key));
			}
			Assert.AreEqual (finalItemSpec, item.FinalItemSpec, prefix + "#5");
		}
开发者ID:salloo,项目名称:mono,代码行数:12,代码来源:ProjectTest.cs

示例8: ModifyItemTwiceInSameScope2

        public void ModifyItemTwiceInSameScope2()
        {
            Hashtable table1 = new Hashtable(StringComparer.OrdinalIgnoreCase);
            Lookup lookup = LookupHelpers.CreateLookup(table1);

            // Add an item with m=m1 and n=n1 and o=o1
            BuildItem item1 = new BuildItem("i1", "a2");
            item1.SetMetadata("m", "m1");
            item1.SetMetadata("n", "n1");
            item1.SetMetadata("o", "o1");
            lookup.PopulateWithItem(item1);

            lookup.EnterScope();

            // It's still m=m1, n=n1, o=o1
            BuildItemGroup group = lookup.GetItems("i1");
            Assertion.AssertEquals(1, group.Count);
            Assertion.AssertEquals("m1", group[0].GetMetadata("m"));
            Assertion.AssertEquals("n1", group[0].GetMetadata("n"));
            Assertion.AssertEquals("o1", group[0].GetMetadata("o"));

            // Make a modification to the item to be m=m2 and n=n2
            Dictionary<string, string> newMetadata = new Dictionary<string, string>();
            newMetadata.Add("m", "m2");
            newMetadata.Add("n", "n2");
            group = new BuildItemGroup();
            group.AddItem(item1);
            lookup.ModifyItems("i1", group, newMetadata);

            // It's now m=m2, n=n2, o=o1
            BuildItemGroup foundGroup = lookup.GetItems("i1");
            Assertion.AssertEquals(1, foundGroup.Count);
            Assertion.AssertEquals("m2", foundGroup[0].GetMetadata("m"));
            Assertion.AssertEquals("n2", foundGroup[0].GetMetadata("n"));
            Assertion.AssertEquals("o1", foundGroup[0].GetMetadata("o"));

            // Make a modification to the item to be n=n3 
            newMetadata = new Dictionary<string, string>();
            newMetadata.Add("n", "n3");
            lookup.ModifyItems("i1", group, newMetadata);

            // It's now m=m2, n=n3, o=o1
            foundGroup = lookup.GetItems("i1");
            Assertion.AssertEquals(1, foundGroup.Count);
            Assertion.AssertEquals("m2", foundGroup[0].GetMetadata("m"));
            Assertion.AssertEquals("n3", foundGroup[0].GetMetadata("n"));
            Assertion.AssertEquals("o1", foundGroup[0].GetMetadata("o"));

            // But the original item hasn't changed yet
            Assertion.AssertEquals("m1", item1.GetMetadata("m"));
            Assertion.AssertEquals("n1", item1.GetMetadata("n"));
            Assertion.AssertEquals("o1", item1.GetMetadata("o"));

            lookup.LeaveScope();

            // It's still m=m2, n=n3, o=o1
            foundGroup = lookup.GetItems("i1");
            Assertion.AssertEquals(1, foundGroup.Count);
            Assertion.AssertEquals("m2", foundGroup[0].GetMetadata("m"));
            Assertion.AssertEquals("n3", foundGroup[0].GetMetadata("n"));
            Assertion.AssertEquals("o1", foundGroup[0].GetMetadata("o"));

            // And the original item has changed
            Assertion.AssertEquals("m2", item1.GetMetadata("m"));
            Assertion.AssertEquals("n3", item1.GetMetadata("n"));
            Assertion.AssertEquals("o1", item1.GetMetadata("o"));
        }
开发者ID:nikson,项目名称:msbuild,代码行数:67,代码来源:Lookup_Tests.cs

示例9: FromFileReference

		private void FromFileReference(BuildItem bi, TranslatePath fnTranslate)
		{
			if (!String.IsNullOrEmpty(bi.Include))
			{
				this.Assembly = new AssemblyName(bi.Include);
				SpecificVersion |= this.Assembly.Version != null;
			}
			if (!String.IsNullOrEmpty(bi.GetMetadata("HintPath")))
			{
				string path = bi.GetMetadata("HintPath");
				fnTranslate(ref path);//< output file doesn't nessessarily exist
				this.Output = path;
			}
			this.RequiresVersion = bi.GetMetadata("RequiredTargetFramework");
		}
开发者ID:hivie7510,项目名称:csharptest-net,代码行数:15,代码来源:ProjectRef.cs

示例10: GetAssemblyPathFromHintPath

 private string GetAssemblyPathFromHintPath(BuildItem item, string projectDir)
 {
     string path = item.GetMetadata(STR_HintPath);
     path = PathUtilities.GetPath(projectDir, path);
     if (File.Exists(path))
     {
         return path;
     }
     return null;
 }
开发者ID:kevinmiles,项目名称:dxcorecommunityplugins,代码行数:10,代码来源:VS2005ProjectLoader.cs

示例11: GetMetadata_EscapedItemSpec

		public void GetMetadata_EscapedItemSpec ()
		{
			string itemInclude = "a;b;c";
			string escapedItemInclude = Utilities.Escape (itemInclude);

			item = new BuildItem ("name", escapedItemInclude);
			Assert.IsTrue (item.GetMetadata ("FullPath").EndsWith (escapedItemInclude), "#1a");
			Assert.IsTrue (item.GetEvaluatedMetadata ("FullPath").EndsWith (itemInclude), "#1b");

			Assert.AreEqual (escapedItemInclude, item.GetMetadata ("FileName"), "#2b");
			Assert.AreEqual (itemInclude, item.GetEvaluatedMetadata ("FileName"), "#2b");

			Assert.AreEqual (escapedItemInclude, item.GetMetadata ("Identity"), "#3a");
			Assert.AreEqual ("a;b;c", item.GetEvaluatedMetadata ("Identity"), "#3b");
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:15,代码来源:BuildItemTest.cs

示例12: ModifyItemInProjectPreviouslyModifiedAndGottenThroughGetItem

        public void ModifyItemInProjectPreviouslyModifiedAndGottenThroughGetItem()
        {
            // Create some project state with an item with m=m1 and n=n1 
            Hashtable table1 = new Hashtable(StringComparer.OrdinalIgnoreCase);
            BuildItem item1 = new BuildItem("i1", "a2");
            item1.SetMetadata("m", "m1");
            BuildItemGroup group0 = new BuildItemGroup();
            group0.AddExistingItem(item1);
            table1["i1"] = group0;

            Lookup lookup = LookupHelpers.CreateLookup(table1);

            lookup.EnterScope();

            // Make a modification to the item to be m=m2
            Dictionary<string, string> newMetadata = new Dictionary<string, string>();
            newMetadata.Add("m", "m2");
            BuildItemGroup group = new BuildItemGroup();
            group.AddItem(item1);
            lookup.ModifyItems(item1.Name, group, newMetadata);

            // Get the item (under the covers, it cloned it in order to apply the modification)
            BuildItemGroup group2 = lookup.GetItems(item1.Name);
            Assertion.AssertEquals(1, group2.Count);
            BuildItem item1b = group2[0];

            // Modify to m=m3
            Dictionary<string, string> newMetadata2 = new Dictionary<string, string>();
            newMetadata2.Add("m", "m3");
            BuildItemGroup group3 = new BuildItemGroup();
            group3.AddItem(item1b);
            lookup.ModifyItems(item1b.Name, group3, newMetadata2);

            // Modifications are visible
            BuildItemGroup group4 = lookup.GetItems(item1b.Name);
            Assertion.AssertEquals(1, group4.Count);
            Assertion.AssertEquals("m3", group4[0].GetMetadata("m"));

            // Leave scope
            lookup.LeaveScope();

            // Still visible
            BuildItemGroup group5 = lookup.GetItems(item1b.Name);
            Assertion.AssertEquals(1, group5.Count);
            Assertion.AssertEquals("m3", group5[0].GetMetadata("m"));

            // And the one in the project is changed
            Assertion.AssertEquals("m3", item1.GetMetadata("m"));
        }
开发者ID:nikson,项目名称:msbuild,代码行数:49,代码来源:Lookup_Tests.cs

示例13: ModifyItemThatWasAddedInSameScope

        public void ModifyItemThatWasAddedInSameScope()
        {
            Hashtable table1 = new Hashtable(StringComparer.OrdinalIgnoreCase);
            Lookup lookup = LookupHelpers.CreateLookup(table1);

            lookup.EnterScope();

            // Add an item with m=m1
            BuildItem item1 = new BuildItem("i1", "a2");
            item1.SetMetadata("m", "m1");
            lookup.AddNewItem(item1);

            // Change the item to be m=m2
            Dictionary<string, string> newMetadata = new Dictionary<string, string>();
            newMetadata.Add("m", "m2");
            BuildItemGroup group = new BuildItemGroup();
            group.AddItem(item1);
            lookup.ModifyItems(item1.Name, group, newMetadata);

            // Now it has m=m2
            group = lookup.GetItems("i1");
            Assertion.AssertEquals(1, group.Count);
            Assertion.AssertEquals("m2", group[0].GetMetadata("m"));

            // But the original item hasn't changed yet
            Assertion.AssertEquals("m1", item1.GetMetadata("m"));

            lookup.LeaveScope();

            // It still has m=m2
            group = lookup.GetItems("i1");
            Assertion.AssertEquals(1, group.Count);
            Assertion.AssertEquals("m2", group[0].GetMetadata("m"));

            // But now the original item has changed as well
            Assertion.AssertEquals("m2", item1.GetMetadata("m"));
        }
开发者ID:nikson,项目名称:msbuild,代码行数:37,代码来源:Lookup_Tests.cs

示例14: CloneVirtual

        public void CloneVirtual()
        {
            BuildItem item = new BuildItem("n", "i");
            item.SetMetadata("m1", "v1");
            item.SetMetadata("m2", "v2");
            BuildItem clone = item.Clone();

            Assertion.AssertEquals("v1", clone.GetMetadata("m1"));
            Assertion.AssertEquals("v2", clone.GetMetadata("m2"));

            clone.SetMetadata("m2", "newValue");

            Assertion.AssertEquals("v2", item.GetMetadata("m2"));
            Assertion.AssertEquals("newValue", clone.GetMetadata("m2"));
        }
开发者ID:nikson,项目名称:msbuild,代码行数:15,代码来源:BuildItem_Tests.cs

示例15: FromProjectReference

		private void FromProjectReference(BuildItem bi, TranslatePath fnTranslate)
		{
			if (!String.IsNullOrEmpty(bi.Include))
			{
				string path = bi.Include;
				if (fnTranslate(ref path))
					this.Project = path;
			}
			if (!String.IsNullOrEmpty(bi.GetMetadata("Project")))
				this.Guid = new Guid(bi.GetMetadata("Project"));
			if (!String.IsNullOrEmpty(bi.GetMetadata("Name")))
				this.Assembly = new AssemblyName(bi.GetMetadata("Name"));
		}
开发者ID:hivie7510,项目名称:csharptest-net,代码行数:13,代码来源:ProjectRef.cs


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