本文整理汇总了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);
}
}
示例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);
}
示例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();
}
示例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);
}
}
示例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;
}
}
示例6: WriteLongstr
public static void WriteLongstr(NetworkBinaryWriter writer, byte[] val)
{
WriteLong(writer, (uint)val.Length);
writer.Write(val);
}
示例7: WriteOctet
public static void WriteOctet(NetworkBinaryWriter writer, byte val)
{
writer.Write((byte)val);
}
示例8: WriteBytes
public static void WriteBytes(NetworkBinaryWriter writer, byte[] value) {
WriteBytes(writer, value, 0, value.Length);
}
示例9: WriteLonglong
public static void WriteLonglong(NetworkBinaryWriter writer, ulong val)
{
writer.Write((ulong)val);
}
示例10: Check
public void Check(NetworkBinaryWriter w, byte[] bytes)
{
Assert.AreEqual(bytes, Contents(w));
}
示例11: Contents
public static byte[] Contents(NetworkBinaryWriter w)
{
return ((MemoryStream)w.BaseStream).ToArray();
}
示例12: WriteDouble
public static void WriteDouble(NetworkBinaryWriter writer, double value) {
writer.Write((byte) StreamWireFormattingTag.Double);
writer.Write(value);
}
示例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);
}
}
示例14: ContentHeaderPropertyWriter
public ContentHeaderPropertyWriter(NetworkBinaryWriter writer)
{
m_writer = writer;
m_flagWord = 0;
m_bitCount = 0;
}
示例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));
}