本文整理汇总了C#中IType.Write方法的典型用法代码示例。如果您正苦于以下问题:C# IType.Write方法的具体用法?C# IType.Write怎么用?C# IType.Write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IType
的用法示例。
在下文中一共展示了IType.Write方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RoundTrip
private object RoundTrip(IType type, object obj)
{
var buffer = new MemoryStream(new byte[type.SizeOf(obj)]);
type.Write(buffer, obj);
//assertFalse("The buffer should now be full.", buffer.hasRemaining());
buffer.Position.Should().Be(buffer.Length);
buffer.Position = 0;
object read = type.Read(buffer);
//assertFalse("All bytes should have been read.", buffer.hasRemaining());
buffer.Position.Should().Be(buffer.Length);
return read;
}
示例2: Write
public void Write(BinaryWriter writer, string name, IType type)
{
long sizePosition = writer.BaseStream.Position;
writer.Seek(4, SeekOrigin.Current);
long startPos = writer.BaseStream.Position;
writer.WriteLpString(name);
writer.Write(type.TypeId);
writer.Write(type.NumFields);
writer.Write(0);
type.Write(writer);
long endPos = writer.BaseStream.Position;
int length = (int)(endPos - startPos);
writer.Seek((int)sizePosition, SeekOrigin.Begin);
writer.Write(length);
writer.Seek((int)endPos, SeekOrigin.Begin);
}