protected static IByteBuffer ToLeakAwareBuffer(IByteBuffer buf)
        {
            IResourceLeak leak;

            switch (ResourceLeakDetector.Level)
            {
            case ResourceLeakDetector.DetectionLevel.Simple:
                leak = AbstractByteBuffer.LeakDetector.Open(buf);
                if (leak != null)
                {
                    buf = new SimpleLeakAwareByteBuf(buf, leak);
                }
                break;

            case ResourceLeakDetector.DetectionLevel.Advanced:
            case ResourceLeakDetector.DetectionLevel.Paranoid:
                leak = AbstractByteBuffer.LeakDetector.Open(buf);
                if (leak != null)
                {
                    buf = new AdvancedLeakAwareByteBuf(buf, leak);
                }
                break;

            case ResourceLeakDetector.DetectionLevel.Disabled:
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            return(buf);
        }
 protected static IByteBuffer ToLeakAwareBuffer(IByteBuffer buf)
 {
     IResourceLeak leak;
     switch (ResourceLeakDetector.Level)
     {
         case ResourceLeakDetector.DetectionLevel.Simple:
             leak = AbstractByteBuffer.LeakDetector.Open(buf);
             if (leak != null)
             {
                 buf = new SimpleLeakAwareByteBuf(buf, leak);
             }
             break;
         case ResourceLeakDetector.DetectionLevel.Advanced:
         case ResourceLeakDetector.DetectionLevel.Paranoid:
             leak = AbstractByteBuffer.LeakDetector.Open(buf);
             if (leak != null)
             {
                 buf = new AdvancedLeakAwareByteBuf(buf, leak);
             }
             break;
         case ResourceLeakDetector.DetectionLevel.Disabled:
             break;
         default:
             throw new ArgumentOutOfRangeException();
     }
     return buf;
 }