public static TTransport GetTransport() { // create transport and protocol objects TTransport transport = new TMemoryBuffer(); TProtocol protocol = new TBinaryProtocol(transport); // Increase recursion depth protocol.IncrementRecursionDepth(); return transport; }
TProtocol protocol = new TBinaryProtocol(transport); int currentDepth = protocol.GetRecursionDepth(); // Increment depth if necessary if (currentDepth < MAX_DEPTH) { protocol.IncrementRecursionDepth(); }This example demonstrates how to increment the maximum recursion depth if necessary before encoding or decoding a message. The currentRecursionDepth can be obtained with the GetRecursionDepth() method. If the current depth is less than the maximum allowed depth, then the IncrementRecursionDepth() method can be called. Package/Library: The TProtocol class is part of the Apache Thrift library, and can be found in the C# Thrift library under the Apache namespace.