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


C# Foo.GetFilePath方法代码示例

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


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

示例1: Main

	static void Main (string [] args)
	{
		AppDomainSetup setup = new AppDomainSetup ();

		string basedir = AppDomain.CurrentDomain.BaseDirectory;
		setup.ConfigurationFile = Path.Combine (AppDomain.CurrentDomain.BaseDirectory,
			"t46.exe.config2");

		AppDomain domain = AppDomain.CreateDomain ("test",
			AppDomain.CurrentDomain.Evidence, setup);

		Program p;
		Foo f;
		Configuration c;

		p = GetRemote (domain);
		Assert.AreEqual (Path.Combine (basedir, "t46.exe.config2"),
			p.GetFilePath (string.Empty), "#A1");
		Assert.AreEqual ("Hello World2!",
			p.GetSettingValue (string.Empty, "hithere"), "#A2");
		Assert.AreEqual (Path.Combine (basedir, "t46.exe.config2"),
			p.GetFilePath ((string) null), "#A3");
		Assert.AreEqual ("Hello World2!",
			p.GetSettingValue ((string) null, "hithere"), "#A4");

		p = new Program ();

		c = p.OpenExeConfiguration (string.Empty);
		Assert.AreEqual (Path.Combine (basedir, "t46.exe.config"),
			c.FilePath, "#B1");
		Assert.AreEqual ("Hello World!",
			c.AppSettings.Settings ["hithere"].Value, "#B2");
		c = p.OpenExeConfiguration ((string) null);
		Assert.AreEqual (Path.Combine (basedir, "t46.exe.config"),
			c.FilePath, "#B3");
		Assert.AreEqual ("Hello World!",
			c.AppSettings.Settings ["hithere"].Value, "#B4");
	
		f = Foo.GetRemote (domain);
		Assert.AreEqual (Path.Combine (basedir, "t46.exe.config2"),
			f.GetFilePath (string.Empty), "#C1");
		Assert.AreEqual ("Hello World2!",
			f.GetSettingValue (string.Empty, "hithere"), "#C2");
		Assert.AreEqual (Path.Combine (basedir, "t46.exe.config2"),
			f.GetFilePath ((string) null), "#C1");
		Assert.AreEqual ("Hello World2!",
			f.GetSettingValue ((string) null, "hithere"), "#C2");

		f = new Foo ();
		c = f.OpenExeConfiguration (string.Empty);
		Assert.AreEqual (Path.Combine (basedir, "t46.exe.config"),
			c.FilePath, "#D1");
		Assert.AreEqual ("Hello World!",
			c.AppSettings.Settings ["hithere"].Value, "#D2");
		c = f.OpenExeConfiguration ((string) null);
		Assert.AreEqual (Path.Combine (basedir, "t46.exe.config"),
			c.FilePath, "#D1");
		Assert.AreEqual ("Hello World!",
			c.AppSettings.Settings ["hithere"].Value, "#D2");

		AppDomain.Unload (domain);

		setup = new AppDomainSetup ();
		domain = AppDomain.CreateDomain ("test",
			AppDomain.CurrentDomain.Evidence, setup);

		p = GetRemote (domain);
		Assert.AreEqual (Path.Combine (basedir, "t46.exe.config"),
			p.GetFilePath (string.Empty), "#E1");
		Assert.AreEqual ("Hello World!",
			p.GetSettingValue (string.Empty, "hithere"), "#E2");

		p = new Program ();

		c = p.OpenExeConfiguration (string.Empty);
		Assert.AreEqual (Path.Combine (basedir, "t46.exe.config"),
			c.FilePath, "#F1");
		Assert.AreEqual ("Hello World!",
			c.AppSettings.Settings ["hithere"].Value, "#F2");

		f = Foo.GetRemote (domain);
		Assert.AreEqual (Path.Combine (basedir, "t46.exe.config"),
			f.GetFilePath (string.Empty), "#G1");
		Assert.AreEqual ("Hello World!",
			f.GetSettingValue (string.Empty, "hithere"), "#G2");

		f = new Foo ();
		c = f.OpenExeConfiguration (string.Empty);
		Assert.AreEqual (Path.Combine (basedir, "t46.exe.config"),
			c.FilePath, "#H1");
		Assert.AreEqual ("Hello World!",
			c.AppSettings.Settings ["hithere"].Value, "#H2");

		Console.WriteLine ("configuration OK");
	}
开发者ID:nlhepler,项目名称:mono,代码行数:95,代码来源:t46.cs


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