本文整理汇总了C#中StreamWriter.WriteInt16方法的典型用法代码示例。如果您正苦于以下问题:C# StreamWriter.WriteInt16方法的具体用法?C# StreamWriter.WriteInt16怎么用?C# StreamWriter.WriteInt16使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StreamWriter
的用法示例。
在下文中一共展示了StreamWriter.WriteInt16方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Serialize
public void Serialize(
StreamWriter streamWriter,
SerializationContext serializationContext,
object value,
PropertyMetaData propertyMetaData = null)
{
streamWriter.WriteInt16((short)value);
}
示例2: Serialize
public void Serialize(
StreamWriter streamWriter,
SerializationContext serializationContext,
object value,
PropertyMetaData propertyMetaData = null)
{
var header = (Header)value;
streamWriter.WriteUInt16(header.MessageId);
streamWriter.WriteInt16((short)header.PacketType);
streamWriter.WriteInt16(header.Unknown);
streamWriter.WriteInt16(header.Size);
streamWriter.WriteInt32(header.Sender);
streamWriter.WriteInt32(header.Receiver);
}
示例3: Serialize
public void Serialize(
StreamWriter streamWriter,
SerializationContext serializationContext,
object value,
PropertyMetaData propertyMetaData = null)
{
if ((this.arraySizeType == ArraySizeType.NoSerialization)|| (this.arraySizeType==ArraySizeType.NullTerminated))
{
return;
}
var array = value as Array;
var length = array != null ? array.Length : ((string)value).Length;
switch (this.arraySizeType)
{
case ArraySizeType.NoSerialization:
break;
case ArraySizeType.Byte:
streamWriter.WriteByte((byte)length);
break;
case ArraySizeType.Int16:
streamWriter.WriteInt16((short)length);
break;
case ArraySizeType.Int32:
streamWriter.WriteInt32(length);
break;
case ArraySizeType.X3F1:
streamWriter.WriteInt32((length + 1) * 0x03F1);
break;
default:
throw new ArgumentOutOfRangeException();
}
}