private static void WriteChars(string pString, IStreamOutput pOutput) { if (pString == null) { pOutput.WriteInt(255); return; } int length = pString.Length; // pString.Length == index 3 if (length >= 128) { // offset 7 pOutput.WriteByte(length >> 16 | 0x80); pOutput.WriteByte(length >> 8 & 0xff); pOutput.WriteByte(length & 0xff); } //offset 16 pOutput.WriteByte(length); if (length > 0) { pOutput.WriteChars(pString); } }
private void Write(Object pObject, int pIndex, IStreamOutput pOutput) { List <int> localNodeIndices = _nodeIndices[pIndex]; for (int i = 0; i < localNodeIndices.Count; i++) { int i6 = localNodeIndices[i]; switch (i6) { case 0: pOutput.WriteByte((byte)pObject); // Byte break; case 1: pOutput.WriteBoolean((bool)pObject); break; case 2: pOutput.WriteByte((byte)pObject); break; case 3: pOutput.WriteShort((short)pObject); break; case 4: pOutput.WriteInt((int)pObject); break; case 5: pOutput.WriteLong((long)pObject); break; case 6: pOutput.WriteFloat((float)pObject); break; case 7: pOutput.WriteDouble((double)pObject); break; case 8: pOutput.WriteChar((char)pObject); break; case 9: pOutput.WriteUTF((string)pObject); break; case 10: break; case 11: i++; i6 = localNodeIndices[i]; string localNodeName = _nodeNames[i6]; var listOfObjects = ((GenericProtocol)pObject).Get <List <object> >(localNodeName); if (listOfObjects == null) { pOutput.WriteByte(12); i++; break; } foreach (var t in listOfObjects) { pOutput.WriteByte(11); Write(t, i6, pOutput); } pOutput.WriteByte(12); i++; break; case 12: // Ende der Liste break; case 13: WriteChars((string)pObject, pOutput); break; default: Write(((GenericProtocol)pObject).Get <object>(_nodeNames[i6]), i6, pOutput); break; } } }