public override string ToString() { StringBuilder headerTLVBuilder = new StringBuilder(); headerTLVBuilder.Append(String.Format(System.Globalization.CultureInfo.InvariantCulture, "Header TLVs ({0}) : ", headerTLVs.Count.ToString(System.Globalization.CultureInfo.InvariantCulture))); if (headerTLVs.Count > 0) { foreach (KeyValuePair <byte, byte[]> keyvalue in headerTLVs) { headerTLVBuilder.Append(String.Format(System.Globalization.CultureInfo.InvariantCulture, "{1:x}({0}),", keyvalue.Key.ToString(System.Globalization.CultureInfo.InvariantCulture), keyvalue.Key)); headerTLVBuilder.Append(String.Format(System.Globalization.CultureInfo.InvariantCulture, "{1:x}({0}),( ", keyvalue.Value.Length.ToString(System.Globalization.CultureInfo.InvariantCulture), keyvalue.Value.Length)); foreach (byte b in keyvalue.Value) { headerTLVBuilder.Append(String.Format(System.Globalization.CultureInfo.InvariantCulture, "0x{0:x2} ", b)); } headerTLVBuilder.Append("); "); } } headerTLVBuilder.Append("\r\n"); StringBuilder bodyTLVBuilder = new StringBuilder(); bodyTLVBuilder.Append(String.Format(System.Globalization.CultureInfo.InvariantCulture, " DataPacket TLVs ({0}): ", dataPacketTLVs.Count.ToString(System.Globalization.CultureInfo.InvariantCulture))); if (dataPacketTLVs.Count > 0) { foreach (KeyValuePair <byte, byte[]> keyvalue in dataPacketTLVs) { bodyTLVBuilder.Append(String.Format(System.Globalization.CultureInfo.InvariantCulture, "{1:x}({0}),", keyvalue.Key.ToString(System.Globalization.CultureInfo.InvariantCulture), keyvalue.Key)); bodyTLVBuilder.Append(String.Format(System.Globalization.CultureInfo.InvariantCulture, "{1:x}({0}),( ", keyvalue.Value.Length.ToString(System.Globalization.CultureInfo.InvariantCulture), keyvalue.Value.Length)); foreach (byte b in keyvalue.Value) { bodyTLVBuilder.Append(String.Format(System.Globalization.CultureInfo.InvariantCulture, "0x{0:x2} ", b)); } bodyTLVBuilder.Append("); "); } } bodyTLVBuilder.Append("\r\n"); int dataHeaderLen = DataPacketHeaderLength; return("[P2Pv2Header]\r\n" + String.Format(System.Globalization.CultureInfo.InvariantCulture, "HeaderLength : {1:x} ({0})\r\n", HeaderLength.ToString(System.Globalization.CultureInfo.InvariantCulture), HeaderLength) + String.Format(System.Globalization.CultureInfo.InvariantCulture, "OperationCode : {1:x} ({0})\r\n", (byte)OperationCode, Convert.ToString(OperationCode)) + String.Format(System.Globalization.CultureInfo.InvariantCulture, "MessageSize : {1:x} ({0})\r\n", MessageSize.ToString(System.Globalization.CultureInfo.InvariantCulture), MessageSize) + String.Format(System.Globalization.CultureInfo.InvariantCulture, "Identifier : {1:x} ({0})\r\n", Identifier.ToString(System.Globalization.CultureInfo.InvariantCulture), Identifier) + String.Format(System.Globalization.CultureInfo.InvariantCulture, "AckIdentifier : {1:x} ({0})\r\n", AckIdentifier.ToString(System.Globalization.CultureInfo.InvariantCulture), AckIdentifier) + String.Format(System.Globalization.CultureInfo.InvariantCulture, "NakIdentifier : {1:x} ({0})\r\n", NakIdentifier.ToString(System.Globalization.CultureInfo.InvariantCulture), NakIdentifier) + headerTLVBuilder.ToString() + String.Format(System.Globalization.CultureInfo.InvariantCulture, " Data HeaderLength : {1:x} ({0})\r\n", dataHeaderLen.ToString(System.Globalization.CultureInfo.InvariantCulture), dataHeaderLen) + String.Format(System.Globalization.CultureInfo.InvariantCulture, " TFCombination : {1:x} ({0})\r\n", (byte)TFCombination, Convert.ToString(TFCombination)) + String.Format(System.Globalization.CultureInfo.InvariantCulture, " PackageNumber : {1:x} ({0})\r\n", PackageNumber.ToString(System.Globalization.CultureInfo.InvariantCulture), PackageNumber) + String.Format(System.Globalization.CultureInfo.InvariantCulture, " SessionId : {1:x} ({0})\r\n", SessionId.ToString(System.Globalization.CultureInfo.InvariantCulture), SessionId) + String.Format(System.Globalization.CultureInfo.InvariantCulture, " DataRemaining : {1:x} ({0})\r\n", DataRemaining.ToString(System.Globalization.CultureInfo.InvariantCulture), DataRemaining) + bodyTLVBuilder.ToString()); }
public override string ToString() { return("[P2Pv1Header]\r\n" + String.Format(System.Globalization.CultureInfo.InvariantCulture, "SessionId : {1:x} ({0})\r\n", SessionId.ToString(System.Globalization.CultureInfo.InvariantCulture), SessionId) + String.Format(System.Globalization.CultureInfo.InvariantCulture, "Identifier : {1:x} ({0})\r\n", Identifier.ToString(System.Globalization.CultureInfo.InvariantCulture), Identifier) + String.Format(System.Globalization.CultureInfo.InvariantCulture, "Offset : {1:x} ({0})\r\n", Offset.ToString(System.Globalization.CultureInfo.InvariantCulture), Offset) + String.Format(System.Globalization.CultureInfo.InvariantCulture, "TotalSize : {1:x} ({0})\r\n", TotalSize.ToString(System.Globalization.CultureInfo.InvariantCulture), TotalSize) + String.Format(System.Globalization.CultureInfo.InvariantCulture, "MessageSize : {1:x} ({0})\r\n", MessageSize.ToString(System.Globalization.CultureInfo.InvariantCulture), MessageSize) + String.Format(System.Globalization.CultureInfo.InvariantCulture, "Flags : {1:x} ({0})\r\n", (uint)Flags, Convert.ToString(Flags)) + String.Format(System.Globalization.CultureInfo.InvariantCulture, "AckSessionId : {1:x} ({0})\r\n", AckSessionId.ToString(System.Globalization.CultureInfo.InvariantCulture), AckSessionId) + String.Format(System.Globalization.CultureInfo.InvariantCulture, "AckIdentifier : {1:x} ({0})\r\n", AckIdentifier.ToString(System.Globalization.CultureInfo.InvariantCulture), AckIdentifier) + String.Format(System.Globalization.CultureInfo.InvariantCulture, "AckTotalSize : {1:x} ({0})\r\n", AckTotalSize.ToString(System.Globalization.CultureInfo.InvariantCulture), AckTotalSize)); }