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


C# Stream.WriteShort方法代码示例

本文整理汇总了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);
 }
开发者ID:priyaparul,项目名称:CqlSharp,代码行数:8,代码来源:ExecuteFrame.cs

示例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());
            }
        }
开发者ID:reuzel,项目名称:CqlSharp,代码行数:56,代码来源:BatchFrame.cs

示例3: WriteToStream

 public override void WriteToStream(Stream aStream)
 {
     base.WriteToStream (aStream);
     aStream.WriteShort (SlotID);
 }
开发者ID:rbrian,项目名称:mccslib,代码行数:5,代码来源:Packets.cs

示例4: WriteMessageIdentifier

 protected void WriteMessageIdentifier(Stream stream) {
     stream.WriteShort(MessageIdentifier);
 }
开发者ID:fm0597,项目名称:nmqtt,代码行数:3,代码来源:MqttVariableHeader.cs

示例5: WriteKeepAlive

 protected void WriteKeepAlive(Stream stream) {
     stream.WriteShort(KeepAlive);
 }
开发者ID:fm0597,项目名称:nmqtt,代码行数:3,代码来源:MqttVariableHeader.cs

示例6: WriteData

 protected override void WriteData(Stream buffer)
 {
     buffer.WriteLongString(Cql);
     buffer.WriteShort((short) CqlConsistency);
 }
开发者ID:priyaparul,项目名称:CqlSharp,代码行数:5,代码来源:QueryFrame.cs

示例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
        }
开发者ID:reuzel,项目名称:CqlSharp,代码行数:36,代码来源:QueryFrameBase.cs


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