本文整理汇总了C#中Stream.WriteShort方法的典型用法代码示例。如果您正苦于以下问题:C# Stream.WriteShort方法的具体用法?C# Stream.WriteShort怎么用?C# Stream.WriteShort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stream
的用法示例。
在下文中一共展示了Stream.WriteShort方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteData
protected override void WriteData(Stream buffer)
{
buffer.WriteShortByteArray(QueryId);
buffer.WriteShort((short)Parameters.Count);
foreach (var prm in Parameters)
buffer.WriteByteArray(prm);
buffer.WriteShort((short)CqlConsistency);
}
示例2: WriteData
/// <summary>
/// Writes the data to buffer.
/// </summary>
/// <param name="buffer"> The buffer. </param>
protected override void WriteData(Stream buffer)
{
if(ProtocolVersion == 1)
{
throw new ProtocolException(ProtocolVersion, ErrorCode.Protocol, "Batch frames are supported from Cassandra Version 2.0.0 and up.");
}
buffer.WriteByte((byte)Type);
buffer.WriteShort((ushort)Commands.Count);
foreach(var command in Commands)
{
if(command.IsPrepared)
{
buffer.WriteByte(1);
buffer.WriteShortByteArray(command.QueryId);
}
else
{
buffer.WriteByte(0);
buffer.WriteLongString(command.CqlQuery);
}
if(command.ParameterValues != null)
{
byte[][] paramValues = command.ParameterValues.Serialize(ProtocolVersion);
var length = (ushort)paramValues.Length;
buffer.WriteShort(length);
for(var i = 0; i < length; i++)
{
buffer.WriteByteArray(paramValues[i]);
}
}
else
buffer.WriteShort(0);
}
buffer.WriteConsistency(CqlConsistency);
if(ProtocolVersion >= 3)
{
var flags = (byte)((SerialConsistency.HasValue ? 16 : 0) |
(Timestamp.HasValue ? 32 : 0));
buffer.WriteByte(flags);
if(SerialConsistency.HasValue)
buffer.WriteShort((ushort)SerialConsistency.Value);
if(Timestamp.HasValue)
buffer.WriteLong(Timestamp.Value.ToTimestamp());
}
}
示例3: WriteToStream
public override void WriteToStream(Stream aStream)
{
base.WriteToStream (aStream);
aStream.WriteShort (SlotID);
}
示例4: WriteMessageIdentifier
protected void WriteMessageIdentifier(Stream stream) {
stream.WriteShort(MessageIdentifier);
}
示例5: WriteKeepAlive
protected void WriteKeepAlive(Stream stream) {
stream.WriteShort(KeepAlive);
}
示例6: WriteData
protected override void WriteData(Stream buffer)
{
buffer.WriteLongString(Cql);
buffer.WriteShort((short) CqlConsistency);
}
示例7: WriteQueryParameters
/// <summary>
/// Writes the query parameters.
/// </summary>
/// <param name="buffer">The buffer.</param>
protected void WriteQueryParameters(Stream buffer)
{
buffer.WriteConsistency(CqlConsistency);
var flags = (byte)((Parameters != null ? 1 : 0) |
(SkipMetaData ? 2 : 0) |
(PageSize.HasValue ? 4 : 0) |
(PagingState != null ? 8 : 0) |
(SerialConsistency.HasValue ? 16 : 0) |
(ProtocolVersion >= 3 && Timestamp.HasValue ? 32 : 0));
buffer.WriteByte(flags);
if(Parameters != null)
{
buffer.WriteShort((ushort)Parameters.Count);
foreach(var value in Parameters)
buffer.WriteByteArray(value);
}
if(PageSize.HasValue)
buffer.WriteInt(PageSize.Value);
if(PagingState != null)
buffer.WriteByteArray(PagingState);
if(SerialConsistency.HasValue)
buffer.WriteShort((ushort)SerialConsistency.Value);
if(ProtocolVersion >= 3 && Timestamp.HasValue)
buffer.WriteLong(Timestamp.Value.ToTimestamp()*1000); //convert milliseconds to microseconds
}