本文整理汇总了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 ();
}
示例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();
}
示例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 ();
}
示例4: WriteByte_Stream_Closed
public void WriteByte_Stream_Closed ()
{
UnmanagedMemoryStream ums = new UnmanagedMemoryStream(mem_byteptr,
length, length, FileAccess.Write);
ums.Close();
ums.WriteByte(0x12);
}
示例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");
}