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


C# Util.NetworkBinaryWriter类代码示例

本文整理汇总了C#中RabbitMQ.Util.NetworkBinaryWriter的典型用法代码示例。如果您正苦于以下问题:C# NetworkBinaryWriter类的具体用法?C# NetworkBinaryWriter怎么用?C# NetworkBinaryWriter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


NetworkBinaryWriter类属于RabbitMQ.Util命名空间,在下文中一共展示了NetworkBinaryWriter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: WriteMap

        /// <param name="writer">Type is <seealso cref="RabbitMQ.Util.NetworkBinaryWriter"/>.</param>
        /// <param name="table">Type is <seealso cref="System.Collections.Generic.IDictionary{TKey,TValue}"/>.</param>
        public static void WriteMap(NetworkBinaryWriter writer, IDictionary<string, object> table) {
            int entryCount = table.Count;
            BytesWireFormatting.WriteInt32(writer, entryCount);

            foreach (KeyValuePair<string, object> entry in table) {
                StreamWireFormatting.WriteUntypedString(writer, (string) entry.Key);
                StreamWireFormatting.WriteObject(writer, entry.Value);
            }
        }
开发者ID:DarthZar,项目名称:rabbitmq-dotnet-client,代码行数:11,代码来源:MapWireFormatting.cs

示例2: SocketFrameHandler_0_9

        public SocketFrameHandler_0_9(AmqpTcpEndpoint endpoint)
        {
            m_endpoint = endpoint;
            m_socket = new TcpClient();
            m_socket.Connect(endpoint.HostName, endpoint.Port);
            // disable Nagle's algorithm, for more consistently low latency 
            m_socket.NoDelay = true;

            Stream netstream = m_socket.GetStream();
            m_reader = new NetworkBinaryReader(netstream);
            m_writer = new NetworkBinaryWriter(netstream);
        }
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:12,代码来源:SocketFrameHandler_0_9.cs

示例3: MethodArgumentWriter

        public MethodArgumentWriter(NetworkBinaryWriter writer)
        {
            m_writer = writer;
            if (!m_writer.BaseStream.CanSeek)
            {
                //FIXME: Consider throwing System.IO.IOException
                // with message indicating that the specified writer does not support Seeking

                // Only really a problem if we try to write a table,
                // but complain anyway. See WireFormatting.WriteTable
                throw new NotSupportedException("Cannot write method arguments to non-positionable stream");
            }
            ResetBitAccumulator();
        }
开发者ID:REALTOBIZ,项目名称:mono,代码行数:14,代码来源:MethodArgumentWriter.cs

示例4: CheckEmptyFrameSize

        public static void CheckEmptyFrameSize() {
            Frame f = new Frame(CommonFraming.Constants.FrameBody, 0, m_emptyByteArray);
            MemoryStream stream = new MemoryStream();
            NetworkBinaryWriter writer = new NetworkBinaryWriter(stream);
            f.WriteTo(writer);
            long actualLength = stream.Length;

            if (EmptyFrameSize != actualLength) {
                string message =
                    string.Format("EmptyFrameSize is incorrect - defined as {0} where the computed value is in fact {1}.",
                                  EmptyFrameSize,
                                  actualLength);
                throw new ProtocolViolationException(message);
            }
        }
开发者ID:DarthZar,项目名称:rabbitmq-dotnet-client,代码行数:15,代码来源:Command.cs

示例5: Check

 public void Check(NetworkBinaryWriter w, byte[] expected)
 {
     byte[] actual = Contents(w);
     try
     {
         Assert.AreEqual(expected, actual);
     }
     catch
     {
         Console.WriteLine();
         Console.WriteLine("EXPECTED ==================================================");
         DebugUtil.Dump(expected);
         Console.WriteLine("ACTUAL ====================================================");
         DebugUtil.Dump(actual);
         Console.WriteLine("===========================================================");
         throw;
     }
 }
开发者ID:TheHunter,项目名称:rabbitmq-dotnet-client,代码行数:18,代码来源:WireFormattingFixture.cs

示例6: WriteLongstr

 public static void WriteLongstr(NetworkBinaryWriter writer, byte[] val)
 {
     WriteLong(writer, (uint)val.Length);
     writer.Write(val);
 }
开发者ID:parshim,项目名称:rabbitmq-dotnet-client,代码行数:5,代码来源:WireFormatting.cs

示例7: WriteOctet

 public static void WriteOctet(NetworkBinaryWriter writer, byte val)
 {
     writer.Write((byte)val);
 }
开发者ID:parshim,项目名称:rabbitmq-dotnet-client,代码行数:4,代码来源:WireFormatting.cs

示例8: WriteBytes

 public static void WriteBytes(NetworkBinaryWriter writer, byte[] value) {
     WriteBytes(writer, value, 0, value.Length);
 }
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:3,代码来源:StreamWireFormatting.cs

示例9: WriteLonglong

 public static void WriteLonglong(NetworkBinaryWriter writer, ulong val)
 {
     writer.Write((ulong)val);
 }
开发者ID:parshim,项目名称:rabbitmq-dotnet-client,代码行数:4,代码来源:WireFormatting.cs

示例10: Check

 public void Check(NetworkBinaryWriter w, byte[] bytes)
 {
     Assert.AreEqual(bytes, Contents(w));
 }
开发者ID:eswann,项目名称:rabbitmq-dotnet-client,代码行数:4,代码来源:TestNetworkBinaryCodec.cs

示例11: Contents

 public static byte[] Contents(NetworkBinaryWriter w)
 {
     return ((MemoryStream)w.BaseStream).ToArray();
 }
开发者ID:TheHunter,项目名称:rabbitmq-dotnet-client,代码行数:4,代码来源:WireFormattingFixture.cs

示例12: WriteDouble

 public static void WriteDouble(NetworkBinaryWriter writer, double value) {
     writer.Write((byte) StreamWireFormattingTag.Double);
     writer.Write(value);
 }
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:4,代码来源:StreamWireFormatting.cs

示例13: WriteTable

        ///<summary>Writes an AMQP "table" to the writer.</summary>
        ///<remarks>
        ///<para>
        /// In this method, we assume that the stream that backs our
        /// NetworkBinaryWriter is a positionable stream - which it is
        /// currently (see Frame.m_accumulator, Frame.GetWriter and
        /// Command.Transmit).
        ///</para>
        ///<para>
        /// Supports the AMQP 0-8/0-9 standard entry types S, I, D, T
        /// and F, as well as the QPid-0-8 specific b, d, f, l, s, t
        /// x and V types and the AMQP 0-9-1 A type.
        ///</para>
        ///</remarks>
        public static void WriteTable(NetworkBinaryWriter writer, IDictionary val)
        {
            if (val == null)
            {
                writer.Write((uint)0);
            }
            else
            {
                Stream backingStream = writer.BaseStream;
                long patchPosition = backingStream.Position;
                writer.Write((uint)0); // length of table - will be backpatched

                foreach (DictionaryEntry entry in val)
                {
                    WriteShortstr(writer, (string)entry.Key);
                    object value = entry.Value;
                    WriteFieldValue(writer, value);
                }

                // Now, backpatch the table length.
                long savedPosition = backingStream.Position;
                long tableLength = savedPosition - patchPosition - 4; // offset for length word
                backingStream.Seek(patchPosition, SeekOrigin.Begin);
                writer.Write((uint)tableLength);
                backingStream.Seek(savedPosition, SeekOrigin.Begin);
            }
        }
开发者ID:parshim,项目名称:rabbitmq-dotnet-client,代码行数:41,代码来源:WireFormatting.cs

示例14: ContentHeaderPropertyWriter

 public ContentHeaderPropertyWriter(NetworkBinaryWriter writer)
 {
     m_writer = writer;
     m_flagWord = 0;
     m_bitCount = 0;
 }
开发者ID:jkff,项目名称:rabbitmq-dotnet-client,代码行数:6,代码来源:ContentHeaderPropertyWriter.cs

示例15: SocketFrameHandler

        public SocketFrameHandler(AmqpTcpEndpoint endpoint,
                                  ConnectionFactory.ObtainSocket socketFactory,
                                  int timeout)
        {
            m_endpoint = endpoint;
            m_socket = null;
            if (Socket.OSSupportsIPv6)
            {
                try
                {
                    m_socket = socketFactory(AddressFamily.InterNetworkV6);
                    Connect(m_socket, endpoint, timeout);
                }
                catch (ConnectFailureException) // could not connect using IPv6
                {
                    m_socket = null;
                }
                catch (SocketException) // Mono might raise a SocketException when using IPv4 addresses on an OS that supports IPv6
                {
                    m_socket = null;
                }
            }
            if (m_socket == null)
            {
                m_socket = socketFactory(AddressFamily.InterNetwork);
                Connect(m_socket, endpoint, timeout);
            }

            Stream netstream = m_socket.GetStream();
            if (endpoint.Ssl.Enabled)
            {
                try
                {
                    netstream = SslHelper.TcpUpgrade(netstream, endpoint.Ssl, timeout);
                }
                catch (Exception)
                {
                    Close();
                    throw;
                }
            }
            m_reader = new NetworkBinaryReader(new BufferedStream(netstream));
            m_writer = new NetworkBinaryWriter(new BufferedStream(netstream));
        }
开发者ID:ricardojmendez,项目名称:rabbitmq-dotnet-client,代码行数:44,代码来源:SocketFrameHandler.cs


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