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, entry.Key); StreamWireFormatting.WriteObject(writer, entry.Value); } }
public static IDictionary <string, object> ReadMap(NetworkBinaryReader reader) { int entryCount = BytesWireFormatting.ReadInt32(reader); if (entryCount < 0) { string message = string.Format("Invalid (negative) entryCount: {0}", entryCount); throw new ProtocolViolationException(message); } IDictionary <string, object> table = new Dictionary <string, object>(entryCount); for (int entryIndex = 0; entryIndex < entryCount; entryIndex++) { string key = StreamWireFormatting.ReadUntypedString(reader); object value = StreamWireFormatting.ReadObject(reader); table[key] = value; } return(table); }
/// <summary> /// Reads a <see cref="string"/> from the message body. /// </summary> public string ReadString() { return(StreamWireFormatting.ReadString(Reader)); }
/// <summary> /// Reads a <see cref="float"/> from the message body. /// </summary> public float ReadSingle() { return(StreamWireFormatting.ReadSingle(Reader)); }
/// <summary> /// Reads an <see cref="object"/> from the message body. /// </summary> public object ReadObject() { return(StreamWireFormatting.ReadObject(Reader)); }
/// <summary> /// Reads a <see cref="long"/> from the message body. /// </summary> public long ReadInt64() { return(StreamWireFormatting.ReadInt64(Reader)); }
///<summary>Writes a float value into the message body being assembled.</summary> public IStreamMessageBuilder WriteSingle(float value) { StreamWireFormatting.WriteSingle(Writer, value); return(this); }
/// <summary> /// Reads a <see cref="byte"/> array from the message body. /// The body contains information about the size of the array to read. /// </summary> public byte[] ReadBytes() { return(StreamWireFormatting.ReadBytes(Reader)); }
///<summary>Writes an int value into the message body being assembled.</summary> public IStreamMessageBuilder WriteInt32(int value) { StreamWireFormatting.WriteInt32(Writer, value); return(this); }
///<summary>Writes a bool value into the message body being assembled.</summary> public IStreamMessageBuilder WriteBool(bool value) { StreamWireFormatting.WriteBool(Writer, value); return(this); }
///<summary>Writes an object value into the message body being assembled.</summary> ///<remarks> /// The only permitted types are bool, int, short, byte, char, /// long, float, double, byte[] and string. ///</remarks> public IStreamMessageBuilder WriteObject(object value) { StreamWireFormatting.WriteObject(Writer, value); return(this); }
///<summary>Writes a string value into the message body being assembled.</summary> public IStreamMessageBuilder WriteString(string value) { StreamWireFormatting.WriteString(Writer, value); return(this); }
///<summary>Writes a byte array into the message body being assembled.</summary> public IStreamMessageBuilder WriteBytes(byte[] source) { StreamWireFormatting.WriteBytes(Writer, source); return(this); }
///<summary>Writes a section of a byte array into the message body being assembled.</summary> public IStreamMessageBuilder WriteBytes(byte[] source, int offset, int count) { StreamWireFormatting.WriteBytes(Writer, source, offset, count); return(this); }
///<summary>Writes a double value into the message body being assembled.</summary> public IStreamMessageBuilder WriteDouble(double value) { StreamWireFormatting.WriteDouble(Writer, value); return(this); }
/// <summary> /// Reads a <see cref="bool"/> from the message body. /// </summary> public bool ReadBool() { return(StreamWireFormatting.ReadBool(Reader)); }
/// <summary> /// Reads a <see cref="byte"/> from the message body. /// </summary> public byte ReadByte() { return(StreamWireFormatting.ReadByte(Reader)); }
/// <summary> /// Reads a <see cref="double"/> from the message body. /// </summary> public double ReadDouble() { return(StreamWireFormatting.ReadDouble(Reader)); }
/// <summary> /// Reads a <see cref="char"/> from the message body. /// </summary> public char ReadChar() { return(StreamWireFormatting.ReadChar(Reader)); }
/// <summary> /// Reads a <see cref="short"/> from the message body. /// </summary> public short ReadInt16() { return(StreamWireFormatting.ReadInt16(Reader)); }
/// <summary> /// Reads an <see cref="int"/> from the message body. /// </summary> public int ReadInt32() { return(StreamWireFormatting.ReadInt32(Reader)); }
///<summary>Writes a char value into the message body being assembled.</summary> public IStreamMessageBuilder WriteChar(char value) { StreamWireFormatting.WriteChar(Writer, value); return(this); }