System.Net.WebSockets.WebSocketBuffer.UnwrapWebSocketBuffer C# (CSharp) Method

UnwrapWebSocketBuffer() static private method

static private UnwrapWebSocketBuffer ( Interop buffer, WebSocketProtocolComponent bufferType, IntPtr &bufferData, uint &bufferLength ) : void
buffer Interop
bufferType WebSocketProtocolComponent
bufferData IntPtr
bufferLength uint
return void
        internal static void UnwrapWebSocketBuffer(Interop.WebSocket.Buffer buffer,
            WebSocketProtocolComponent.BufferType bufferType,
            out IntPtr bufferData,
            out uint bufferLength)
        {
            bufferData = IntPtr.Zero;
            bufferLength = 0;

            switch (bufferType)
            {
                case WebSocketProtocolComponent.BufferType.Close:
                    bufferData = buffer.CloseStatus.ReasonData;
                    bufferLength = buffer.CloseStatus.ReasonLength;
                    break;
                case WebSocketProtocolComponent.BufferType.None:
                case WebSocketProtocolComponent.BufferType.BinaryFragment:
                case WebSocketProtocolComponent.BufferType.BinaryMessage:
                case WebSocketProtocolComponent.BufferType.UTF8Fragment:
                case WebSocketProtocolComponent.BufferType.UTF8Message:
                case WebSocketProtocolComponent.BufferType.PingPong:
                case WebSocketProtocolComponent.BufferType.UnsolicitedPong:
                    bufferData = buffer.Data.BufferData;
                    bufferLength = buffer.Data.BufferLength;
                    break;
                default:
                    Debug.Assert(false,
                        string.Format(CultureInfo.InvariantCulture,
                            "BufferType '{0}' is invalid/unknown.",
                            bufferType));
                    break;
            }
        }