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


C# Project.LoadXml方法代码示例

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


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

示例1: TestAssemblyFile2

		public void TestAssemblyFile2 ()
		{
			string documentString = @"
				<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
					<UsingTask
						AssemblyFile='Test/resources/TestTasks.dll'
						TaskName='SimpleTask'
					/>
				</Project>
			";

			engine = new Engine (Consts.BinPath);
			project = engine.CreateNewProject ();
			project.LoadXml (documentString);
			
			IEnumerator en = project.UsingTasks.GetEnumerator ();
			en.MoveNext ();
			
			UsingTask ut = (UsingTask) en.Current;
			
			Assert.AreEqual ("Test/resources/TestTasks.dll", ut.AssemblyFile, "A1");
			Assert.IsNull (ut.AssemblyName, "A2");
			Assert.AreEqual (null, ut.Condition, "A3");
			Assert.AreEqual (false, ut.IsImported, "A4");
			Assert.AreEqual ("SimpleTask", ut.TaskName, "A5");
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:26,代码来源:UsingTaskTest.cs

示例2: TestFromXml2

		public void TestFromXml2 ()
		{
                        string documentString = @"
                                <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
					<Target Name='Target' Condition='false' DependsOnTargets='X' >
					</Target>
                                </Project>
                        ";

			engine = new Engine (Consts.BinPath);

                        project = engine.CreateNewProject ();
                        project.LoadXml (documentString);

			Target[] t = new Target [1];
			project.Targets.CopyTo (t, 0);

			Assert.AreEqual ("false", t [0].Condition, "A1");
			Assert.AreEqual ("X", t [0].DependsOnTargets, "A2");

			t [0].Condition = "true";
			t [0].DependsOnTargets = "A;B";

			Assert.AreEqual ("true", t [0].Condition, "A3");
			Assert.AreEqual ("A;B", t [0].DependsOnTargets, "A4");
		}
开发者ID:ancailliau,项目名称:mono,代码行数:26,代码来源:TargetTest.cs

示例3: TestGetEnumerator

		public void TestGetEnumerator ()
		{
			string documentString = @"
				<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
					<UsingTask
						AssemblyFile='Test/resources/TestTasks.dll'
						TaskName='TrueTestTask'
					/>
					<UsingTask
						AssemblyFile='Test/resources/TestTasks.dll'
						TaskName='FalseTestTask'
					/>
				</Project>
			";

			engine = new Engine (Consts.BinPath);
			project = engine.CreateNewProject ();
			project.LoadXml (documentString);
			
			IEnumerator en = project.UsingTasks.GetEnumerator ();
			en.MoveNext ();

			Assert.AreEqual ("Test/resources/TestTasks.dll", ((UsingTask) en.Current).AssemblyFile, "A1");
			Assert.AreEqual ("TrueTestTask", ((UsingTask) en.Current).TaskName, "A2");

			en.MoveNext ();

			Assert.AreEqual ("Test/resources/TestTasks.dll", ((UsingTask) en.Current).AssemblyFile, "A3");
			Assert.AreEqual ("FalseTestTask", ((UsingTask) en.Current).TaskName, "A4");

			Assert.IsFalse (en.MoveNext ());
		}
开发者ID:nlhepler,项目名称:mono,代码行数:32,代码来源:UsingTaskCollectionTest.cs

示例4: TestHintPath1

		public void TestHintPath1 ()
		{
			engine = new Engine (Consts.BinPath);
			project = engine.CreateNewProject ();
			project.LoadXml (ResolveAssembly (null, @"Test\resources\test.dll"));
			
			Assert.IsTrue (project.Build ("A"), "A1");
			big = project.GetEvaluatedItemsByName ("ResolvedFiles");
			Assert.AreEqual (1, big.Count, "A2");
			Assert.IsTrue (big [0].Include.EndsWith (".dll"), "A3");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:11,代码来源:ResolveAssemblyReferenceTest.cs

示例5: LoadProject

		public override object LoadProject (MSBuildProject p, string xml, FilePath fileName)
		{
			lock (engine) {
				engine.GlobalProperties.Clear ();

				var project = new MSProject (engine);
				project.BuildEnabled = false;
				project.FullFileName = fileName;
				project.LoadXml (xml);
				return project;
			}
		}
开发者ID:zenek-y,项目名称:monodevelop,代码行数:12,代码来源:MSBuildEngineV4.cs

示例6: TestAdd1

		public void TestAdd1 ()
		{
                        string documentString = @"
                                <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
					<Import Project='project_that_doesnt_exist'/>
                                </Project>
                        ";

                        engine = new Engine (Consts.BinPath);

                        project = engine.CreateNewProject ();
                        project.LoadXml (documentString);
		}
开发者ID:nlhepler,项目名称:mono,代码行数:13,代码来源:ImportCollectionTest.cs

示例7: ResolveBinary_FancyStuff

		public void ResolveBinary_FancyStuff ()
		{
			engine = new Engine (Consts.BinPath);
			project = engine.CreateNewProject ();
			project.LoadXml (ResolveAssembly (null, @"Test\resources\binary\FancyStuff.dll"));
			
			Assert.IsTrue (project.Build ("A"), "A1");
			big = project.GetEvaluatedItemsByName ("ResolvedFiles");
			Assert.AreEqual (1, big.Count, "A2");
			Assert.IsTrue (big[0].Include.EndsWith ("FancyStuff.dll"), "A3");
			
			big = project.GetEvaluatedItemsByName ("ResolvedDependencyFiles");
			Assert.AreEqual (1, big.Count, "A4");
			Assert.IsTrue (big.Cast<BuildItem> ().Any (item => item.Include.EndsWith ("SimpleWrite.dll")), "A5");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:15,代码来源:ResolveAssemblyReferenceTest.cs

示例8: TestEmpty

		public void TestEmpty ()
		{
                        string documentString = @"
                                <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
                                </Project>
                        ";

			engine = new Engine (Consts.BinPath);

                        project = engine.CreateNewProject ();
                        project.LoadXml (documentString);

			Assert.AreEqual (0, project.Targets.Count, "A1");
			Assert.IsFalse (project.Targets.IsSynchronized, "A2");
			Assert.IsNotNull (project.Targets.SyncRoot, "A3");
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:16,代码来源:TargetCollectionTest.cs

示例9: TestGac1

		public void TestGac1 ()
		{
			var gacDir = GetGacDir ();

			if (gacDir == null || !System.IO.Directory.Exists (gacDir))
				Assert.Ignore ("GAC not found.");

			engine = new Engine (Consts.BinPath);
			project = engine.CreateNewProject ();
			project.LoadXml (ResolveAssembly ("System", null));
			
			Assert.IsTrue (project.Build ("A"), "A1");
			big = project.GetEvaluatedItemsByName ("ResolvedFiles");
			Assert.AreEqual (1, big.Count, "A2");
			Assert.IsTrue (big [0].Include.EndsWith (".dll"), "A3");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:16,代码来源:ResolveAssemblyReferenceTest.cs

示例10: TestAdd1

		public void TestAdd1 ()
		{
			string first = @"
                                <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
					<Import Project='second.proj'/>
                                </Project>
";
			using (StreamWriter sw = new StreamWriter ("Test/resources/first.proj")) {
				sw.Write (first);
			}

			string second = @"
                                <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
                                </Project>
";
			using (StreamWriter sw = new StreamWriter ("Test/resources/second.proj")) {
				sw.Write (second);
			}

                        string documentString = @"
                                <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
						<Import Project='Test\resources\first.proj'/>
						<Import Project='Test\resources\Import.csproj' Condition='false'/>
                                </Project>
                        ";

                        engine = new Engine (Consts.BinPath);

                        project = engine.CreateNewProject ();
                        project.LoadXml (documentString);

			Import[] t = new Import [2];
			Assert.AreEqual (2, project.Imports.Count, "Number of imports");
			project.Imports.CopyTo (t, 0);

			string base_dir = Path.Combine (Environment.CurrentDirectory, Path.Combine ("Test", "resources"));

			Assert.IsNull (t [0].Condition, "A1");

			Assert.AreEqual (false, t[0].IsImported, "A5");
			Assert.AreEqual ("Test\\resources\\first.proj", t[0].ProjectPath, "A6");
			Assert.AreEqual (Path.Combine (base_dir, "first.proj"), t[0].EvaluatedProjectPath, "A7");

			Assert.AreEqual (true, t[1].IsImported, "A2");
			Assert.AreEqual ("second.proj", t[1].ProjectPath, "A3");
			Assert.AreEqual (Path.Combine (base_dir, "second.proj"), t[1].EvaluatedProjectPath, "A4");
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:47,代码来源:ImportTest.cs

示例11: TestAdd2

		public void TestAdd2 ()
		{
                        string documentString = @"
                                <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
					<Import Project='Test/resources/Import.csproj'/>
					<Import Project='Test/resources/Import.csproj'/>
                                </Project>
                        ";

                        engine = new Engine (Consts.BinPath);

                        project = engine.CreateNewProject ();
                        project.LoadXml (documentString);

			Assert.AreEqual (1, project.Imports.Count, "A1");
			Assert.AreEqual (false, project.Imports.IsSynchronized, "A2");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:17,代码来源:ImportCollectionTest.cs

示例12: TestCopyTo2

		public void TestCopyTo2 ()
		{
			string documentString = @"
				<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
					<ItemGroup>
						<Name Include='Value' />
					</ItemGroup>
				</Project>
			";

			engine = new Engine (Consts.BinPath);

			project = engine.CreateNewProject ();
			project.LoadXml (documentString);
			
			project.ItemGroups.CopyTo (new BuildItemGroup [1], -1);
		}
开发者ID:nlhepler,项目名称:mono,代码行数:17,代码来源:BuildItemGroupCollectionTest.cs

示例13: TestCopyTo1

		public void TestCopyTo1 ()
		{
			string documentString = @"
				<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
					<PropertyGroup>
						<Name>Value</Name>
					</PropertyGroup>
				</Project>
			";

			engine = new Engine (Consts.BinPath);

			project = engine.CreateNewProject ();
			project.LoadXml (documentString);
			
			project.PropertyGroups.CopyTo (null, 0);
		}
开发者ID:nlhepler,项目名称:mono,代码行数:17,代码来源:BuildPropertyGroupCollectionTest.cs

示例14: TestAddNewTarget1

		public void TestAddNewTarget1 ()
		{
                        string documentString = @"
                                <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
                                </Project>
                        ";

			engine = new Engine (Consts.BinPath);

                        project = engine.CreateNewProject ();
                        project.LoadXml (documentString);

			project.Targets.AddNewTarget ("name");

			Assert.AreEqual (1, project.Targets.Count, "A1");
			Assert.AreEqual ("name", project.Targets ["name"].Name, "A2");
			Assert.IsFalse (project.Targets ["name"].IsImported, "A3");
			Assert.AreEqual (String.Empty, project.Targets ["name"].Condition, "A4");
			Assert.AreEqual (String.Empty, project.Targets ["name"].DependsOnTargets, "A5");	
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:20,代码来源:TargetCollectionTest.cs

示例15: TestAssemblyFile1

		public void TestAssemblyFile1 ()
		{
			string documentString = @"
				<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
					<UsingTask
						AssemblyFile='Test/resources/TestTasks.dll'
						TaskName='TrueTestTask'
					/>
				</Project>
			";

                        engine = new Engine (Consts.BinPath);

                        project = engine.CreateNewProject ();
                        project.LoadXml (documentString);
                        
                        Assert.AreEqual (1, project.UsingTasks.Count, "A1");
                        Assert.AreEqual (false, project.UsingTasks.IsSynchronized, "A2");
                        Assert.AreEqual (typeof (object), project.UsingTasks.SyncRoot.GetType (), "A3");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:20,代码来源:UsingTaskCollectionTest.cs


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