當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。