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


C# ResourceManager.GetStream方法代码示例

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


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

示例1: Main


//.........这里部分代码省略.........
		}

#if NET_2_0
		rm = ResourceManager.CreateFileBasedResourceManager (
			"FileComponentB.resources.resources",
			AppDomain.CurrentDomain.BaseDirectory,
			typeof (ResourceSet));
		try {
			rm.GetString ("$this.name");
			Assert.Fail ("#H1");
		} catch (MissingManifestResourceException ex) {
			string expected = CreateMissingOnDisk (
				"FileComponentB.resources.resources");
			Assert.AreEqual (expected, ex.Message, "#H2");
		}
#else
		try {
			ResourceManager.CreateFileBasedResourceManager (
				"FileComponentB.resources.resources",
				AppDomain.CurrentDomain.BaseDirectory,
				typeof (ResourceSet));
			Assert.Fail ("#I1");
		} catch (ArgumentException ex) {
			Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#I2");
			Assert.IsNull (ex.InnerException, "#I3");
			Assert.IsNotNull (ex.Message, "#I4");
			Assert.AreEqual (baseNameErrorMsg, ex.Message, "#I5");
			Assert.IsNull (ex.ParamName, "#I6");
		}
#endif

#if NET_2_0
		rm = ResourceManager.CreateFileBasedResourceManager (
			"FileComponentA.resources",
			AppDomain.CurrentDomain.BaseDirectory,
			typeof (ResourceSet));
		try {
			rm.GetString ("$this.name");
			Assert.Fail ("#J1");
		} catch (MissingManifestResourceException ex) {
			string expected = CreateMissingOnDisk (
				"FileComponentA.resources");
			Assert.AreEqual (expected, ex.Message, "#J2");
		}
#else
		try {
			ResourceManager.CreateFileBasedResourceManager (
				"FileComponentA.resources",
				AppDomain.CurrentDomain.BaseDirectory,
				typeof (ResourceSet));
			Assert.Fail ("#K1");
		} catch (ArgumentException ex) {
			Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#K2");
			Assert.IsNull (ex.InnerException, "#K3");
			Assert.IsNotNull (ex.Message, "#K4");
			Assert.AreEqual (baseNameErrorMsg, ex.Message, "#K5");
			Assert.IsNull (ex.ParamName, "#K6");
		}
#endif

		rm = ResourceManager.CreateFileBasedResourceManager (
			".resources",
			AppDomain.CurrentDomain.BaseDirectory,
			typeof (ResourceSet));
		try {
			rm.GetString ("$this.name");
			Assert.Fail ("#L1");
		} catch (MissingManifestResourceException ex) {
			string expected = CreateMissingOnDisk (
				".resources");
			Assert.AreEqual (expected, ex.Message, "#J2");
		}

		rm = new ResourceManager (typeof (Mono.ResourceTest));
		try {
			rm.GetString ("$this.name");
			Assert.Fail ("#M1");
		} catch (MissingManifestResourceException ex) {
			string expected = CreateMissingInAssembly (
				typeof (Mono.ResourceTest));
			Assert.AreEqual (expected, ex.Message, "#M2");
		}

#if NET_2_0
		rm = ResourceManager.CreateFileBasedResourceManager (
			"DoesNotExist",
			AppDomain.CurrentDomain.BaseDirectory,
			typeof (ResourceSet));
		try {
			rm.GetStream ("$this.name");
			Assert.Fail ("#N1");
		} catch (MissingManifestResourceException ex) {
			string expected = CreateMissingOnDisk (
				"DoesNotExist");
			Assert.AreEqual (expected, ex.Message, "#N2");
		}
#endif

		return 0;
	}
开发者ID:mono,项目名称:gert,代码行数:101,代码来源:test.cs

示例2: GetStream

 public static void GetStream()
 {
     var manager = new ResourceManager("System.Resources.Tests.Resources.TestResx.netstandard17", typeof(ResourceManagerTests).GetTypeInfo().Assembly);
     var culture = new CultureInfo("en-US");
     var expectedBytes = new byte[] { 41, 42, 43, 44, 192, 168, 1, 1 };
     using (Stream stream = manager.GetStream("ByteStream"))
     {
         foreach (byte b in expectedBytes)
         {
             Assert.Equal(b, stream.ReadByte());
         }
     }
     using (Stream stream = manager.GetStream("ByteStream", culture))
     {
         foreach (byte b in expectedBytes)
         {
             Assert.Equal(b, stream.ReadByte());
         }
     }
 }
开发者ID:dotnet,项目名称:corefx,代码行数:20,代码来源:ResourceManagerTests.netstandard17.cs


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