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


C# UnmanagedMemoryStream.WriteByte方法代码示例

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


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

示例1: WriteByte_Stream_ReadOnly

		public void WriteByte_Stream_ReadOnly ()
		{
			UnmanagedMemoryStream ums = new 
				UnmanagedMemoryStream(mem_byteptr, length);
			try {
				ums.WriteByte (testStreamData [0]);
				Assert.Fail ("#1");
			} catch (NotSupportedException ex) {
				// Stream does not support writing
				Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
				Assert.IsNull (ex.InnerException, "#3");
				Assert.IsNotNull (ex.Message, "#4");
			}
			ums.Close ();
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:15,代码来源:UnmanagedMemoryStreamTest.cs

示例2: WriteByte_Capacity_Exceeded

		public void WriteByte_Capacity_Exceeded ()
		{
			UnmanagedMemoryStream ums = new 
				UnmanagedMemoryStream(mem_byteptr, 1, 2, FileAccess.ReadWrite);
			ums.WriteByte (0x44);
			ums.WriteByte (0x45);
			try {
				ums.WriteByte (0x46);
				Assert.Fail ("#1");
			} catch (NotSupportedException ex) {
				// Unable to expand length of this stream beyond its capacity
				Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2");
				Assert.IsNull (ex.InnerException, "#3");
				Assert.IsNotNull (ex.Message, "#4");
			}
			ums.Close();
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:17,代码来源:UnmanagedMemoryStreamTest.cs

示例3: WriteByte

		public void WriteByte ()
		{
			UnmanagedMemoryStream ums = new 
				UnmanagedMemoryStream(mem_byteptr, 3, 5, FileAccess.ReadWrite);
			ums.WriteByte (testStreamData [0]);
			Assert.AreEqual (5, ums.Capacity, "#A1");
			Assert.AreEqual (1, ums.Position, "#A2");
			Assert.AreEqual (3, ums.Length, "#A3");
			ums.WriteByte (testStreamData [1]);
			Assert.AreEqual (5, ums.Capacity, "#B1");
			Assert.AreEqual (2, ums.Position, "#B2");
			Assert.AreEqual (3, ums.Length, "#B3");
			ums.WriteByte (testStreamData [2]);
			Assert.AreEqual (5, ums.Capacity, "#C1");
			Assert.AreEqual (3, ums.Position, "#C2");
			Assert.AreEqual (3, ums.Length, "#C3");
			ums.WriteByte (testStreamData [3]);
			Assert.AreEqual (5, ums.Capacity, "#D1");
			Assert.AreEqual (4, ums.Position, "#D2");
			Assert.AreEqual (4, ums.Length, "#D3");
			ums.WriteByte (testStreamData [4]);
			Assert.AreEqual (5, ums.Capacity, "#E1");
			Assert.AreEqual (5, ums.Position, "#E2");
			Assert.AreEqual (5, ums.Length, "#E3");
			ums.Seek (0, SeekOrigin.Begin);
			Assert.AreEqual (testStreamData [0], ums.ReadByte (), "#F1");
			Assert.AreEqual (testStreamData [1], ums.ReadByte (), "#F2");
			Assert.AreEqual (testStreamData [2], ums.ReadByte (), "#F3");
			Assert.AreEqual (testStreamData [3], ums.ReadByte (), "#F4");
			Assert.AreEqual (testStreamData [4], ums.ReadByte (), "#F5");
			ums.Close ();
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:32,代码来源:UnmanagedMemoryStreamTest.cs

示例4: WriteByte_Stream_Closed

		public void WriteByte_Stream_Closed ()
		{
			UnmanagedMemoryStream ums = new UnmanagedMemoryStream(mem_byteptr,
				length, length, FileAccess.Write);
			ums.Close();
			ums.WriteByte(0x12);
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:7,代码来源:UnmanagedMemoryStreamTest.cs

示例5: PositionPointer_Set

		public void PositionPointer_Set ()
		{
			byte [] n = new byte [8];
			n [4] = 65;
			fixed (byte* p = n) {
				UnmanagedMemoryStream m = new UnmanagedMemoryStream (p, 8, 8, FileAccess.ReadWrite);
				m.PositionPointer = p + 4;
				Assert.AreEqual (65, m.ReadByte (), "read");
				m.WriteByte (42);
			}
			Assert.AreEqual (42, n [5], "write");
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:12,代码来源:UnmanagedMemoryStreamTest.cs


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