protected void WriteInt32List(SubStream outstream, List <int> data) { outstream.WriteInt32(data.Count); foreach (int val in data) { outstream.WriteInt32(val); } }
protected void WriteList(SubStream outstream, IList data) { outstream.WriteInt32(data.Count); foreach (object val in data) { WriteValue(outstream, val); } }
protected void WriteStringList(SubStream outstream, List <string> data) { outstream.WriteInt32(data.Count); foreach (string val in data) { outstream.WriteString(val); } }
protected void WriteSingleList(SubStream outstream, List <float> data) { outstream.WriteInt32(data.Count); foreach (float val in data) { outstream.WriteSingle(val); } }
protected void WriteValue(SubStream outstream, object data) { if (data == null) { outstream.WriteByte((byte)'.'); } else if (data is string) { outstream.WriteByte((byte)'s'); outstream.WriteString((string)data); } else if (data is float) { outstream.WriteByte((byte)'f'); outstream.WriteSingle((float)data); } else if (data is int) { outstream.WriteByte((byte)'i'); outstream.WriteInt32((int)data); } else if (data is byte[]) { outstream.WriteByte((byte)'R'); WriteRawBinary(outstream, (byte[])data); } else if (data is List <string> ) { outstream.WriteByte((byte)'S'); WriteStringList(outstream, (List <string>)data); } else if (data is List <float> ) { outstream.WriteByte((byte)'F'); WriteSingleList(outstream, (List <float>)data); } else if (data is List <int> ) { outstream.WriteByte((byte)'I'); WriteInt32List(outstream, (List <int>)data); } else if (data is IList) { outstream.WriteByte((byte)'M'); WriteList(outstream, (IList)data); } else if (data is IDictionary) { outstream.WriteByte((byte)'T'); WriteKeyValuePairs(outstream, (IDictionary)data); } else { throw new InvalidOperationException(String.Format("Unable to write value of type {0}", data.GetType().ToString())); } }
protected void WriteValue(SubStream outstream, object data) { if (data == null) { outstream.WriteByte((byte)'.'); } else if (data is string) { outstream.WriteByte((byte)'s'); outstream.WriteString((string)data); } else if (data is float) { outstream.WriteByte((byte)'f'); outstream.WriteSingle((float)data); } else if (data is int) { outstream.WriteByte((byte)'i'); outstream.WriteInt32((int)data); } else if (data is byte[]) { outstream.WriteByte((byte)'R'); WriteRawBinary(outstream, (byte[])data); } else if (data is List<string>) { outstream.WriteByte((byte)'S'); WriteStringList(outstream, (List<string>)data); } else if (data is List<float>) { outstream.WriteByte((byte)'F'); WriteSingleList(outstream, (List<float>)data); } else if (data is List<int>) { outstream.WriteByte((byte)'I'); WriteInt32List(outstream, (List<int>)data); } else if (data is IList) { outstream.WriteByte((byte)'M'); WriteList(outstream, (IList)data); } else if (data is IDictionary) { outstream.WriteByte((byte)'T'); WriteKeyValuePairs(outstream, (IDictionary)data); } else { throw new InvalidOperationException(String.Format("Unable to write value of type {0}", data.GetType().ToString())); } }
protected void WriteStringList(SubStream outstream, List<string> data) { outstream.WriteInt32(data.Count); foreach (string val in data) { outstream.WriteString(val); } }
protected void WriteSingleList(SubStream outstream, List<float> data) { outstream.WriteInt32(data.Count); foreach (float val in data) { outstream.WriteSingle(val); } }
protected void WriteRawBinary(SubStream outstream, byte[] data) { outstream.WriteInt32(data.Length); outstream.WriteBytes(data.Length, data); }
protected void WriteInt32List(SubStream outstream, List<int> data) { outstream.WriteInt32(data.Count); foreach (int val in data) { outstream.WriteInt32(val); } }