/// <summary>
        /// Composes rgbAuxIn buffer
        /// </summary>
        /// <param name="rgbAuxIn">Enum value of rgbAuxIn</param>
        /// <param name="rgbAuxInPayload">The payload of rgbAuxIn buffer.</param>
        /// <returns>Returns a buffer composed according to the parameters</returns>
        public static byte[] ComposeRgbAuxIn(RgbAuxInEnum rgbAuxIn, byte[] rgbAuxInPayload)
        {
            byte version;
            byte type;
            const string ErrorMessage = "This input structure name is not a valid AUX structure type";

            // Version set to 0x01 means the Version field of AUX_HEADER is AUX_VERSION_1
            // Version set to 0x02 means the Version field of AUX_HEADER is AUX_VERSION_2
            switch (rgbAuxIn)
            {
                case RgbAuxInEnum.AUX_PERF_SESSIONINFO:
                     version = (byte)AuxVersions.AUX_VERSION_1;
                    type = (byte)AuxTypes.AUX_TYPE_PERF_SESSIONINFO;
                    break;
                case RgbAuxInEnum.AUX_PERF_SESSIONINFO_V2:
                    version = (byte)AuxVersions.AUX_VERSION_2;
                    type = (byte)AuxTypes.AUX_TYPE_PERF_SESSIONINFO;
                    break;
                case RgbAuxInEnum.AUX_PERF_CLIENTINFO:
                    version = (byte)AuxVersions.AUX_VERSION_1;
                    type = (byte)AuxTypes.AUX_TYPE_PERF_CLIENTINFO;
                    break;
                case RgbAuxInEnum.AUX_PERF_PROCESSINFO:
                    version = (byte)AuxVersions.AUX_VERSION_2;
                    type = (byte)AuxTypes.AUX_TYPE_PERF_PROCESSINFO;
                    break;
                case RgbAuxInEnum.AUX_PERF_DEFMDB_SUCCESS:
                    version = (byte)AuxVersions.AUX_VERSION_1;
                    type = (byte)AuxTypes.AUX_TYPE_PERF_BG_DEFMDB_SUCCESS;
                    break;
                case RgbAuxInEnum.AUX_PERF_DEFGC_SUCCESS:
                    version = (byte)AuxVersions.AUX_VERSION_1;
                    type = (byte)AuxTypes.AUX_TYPE_PERF_BG_DEFGC_SUCCESS;
                    break;
                case RgbAuxInEnum.AUX_PERF_MDB_SUCCESS_V2:
                    version = (byte)AuxVersions.AUX_VERSION_2;
                    type = (byte)AuxTypes.AUX_TYPE_PERF_MDB_SUCCESS;
                    break;
                case RgbAuxInEnum.AUX_PERF_GC_SUCCESS:
                    version = (byte)AuxVersions.AUX_VERSION_1;
                    type = (byte)AuxTypes.AUX_TYPE_PERF_BG_GC_SUCCESS;
                    break;
                case RgbAuxInEnum.AUX_PERF_GC_SUCCESS_V2:
                    version = (byte)AuxVersions.AUX_VERSION_2;
                    type = (byte)AuxTypes.AUX_TYPE_PERF_BG_GC_SUCCESS;
                    break;
                case RgbAuxInEnum.AUX_PERF_FAILURE:
                    version = (byte)AuxVersions.AUX_VERSION_1;
                    type = (byte)AuxTypes.AUX_TYPE_PERF_BG_FAILURE;
                    break;
                case RgbAuxInEnum.AUX_PERF_FAILURE_V2:
                     version = (byte)AuxVersions.AUX_VERSION_2;
                    type = (byte)AuxTypes.AUX_TYPE_PERF_BG_FAILURE;
                    break;
                case RgbAuxInEnum.AUX_PERF_ACCOUNTINFO:
                    version = (byte)AuxVersions.AUX_VERSION_1;
                    type = (byte)AuxTypes.AUX_TYPE_PERF_ACCOUNTINFO;
                    break;
                case RgbAuxInEnum.AUX_CLIENT_CONNECTION_INFO:
                    version = (byte)AuxVersions.AUX_VERSION_1;
                    type = (byte)AuxTypes.AUX_CLIENT_CONNECTION_INFO;
                    break;
                default:
                    throw new NotImplementedException(ErrorMessage);
            }

            RPC_HEADER_EXT rpcHeaderExt = new RPC_HEADER_EXT
            {
                Version = 0x0000, // This value MUST be set to 0x0000.
                Flags = (ushort)RpcHeaderExtFlags.Last, // No Compression and no obfuscation
                Size = (ushort)(rgbAuxInPayload.Length + ConstValues.AuxHeaderByteSize) // The total length of the payload data that follows the RPC_HEADER_EXT structure. 
            };

            // The length of the payload data after it has been uncompressed.
            rpcHeaderExt.SizeActual = rpcHeaderExt.Size;

            // The length of AuxHeader is the length of AUX_HEADER structure plus the length of any additional payload data.
            AUX_HEADER auxHeader = new AUX_HEADER
            {
                Size = (ushort)(rgbAuxInPayload.Length + ConstValues.AuxHeaderByteSize),
                Version = version,
                Type = type
            };
            int returnSize = rgbAuxInPayload.Length + Marshal.SizeOf(rpcHeaderExt) + Marshal.SizeOf(auxHeader);
            byte[] returnByte = new byte[returnSize];

            // RgbAuxIn serialization 
            // Serializes the RPC_HEADER_EXT
            int index = 0;
            Array.Copy(BitConverter.GetBytes(rpcHeaderExt.Version), 0, returnByte, index, sizeof(short));
            index += sizeof(short);
            Array.Copy(BitConverter.GetBytes(rpcHeaderExt.Flags), 0, returnByte, index, sizeof(short));
            index += sizeof(short);
            Array.Copy(BitConverter.GetBytes(rpcHeaderExt.Size), 0, returnByte, index, sizeof(short));
            index += sizeof(short);
            Array.Copy(BitConverter.GetBytes(rpcHeaderExt.SizeActual), 0, returnByte, index, sizeof(short));
            index += sizeof(short);

            // Serializes the AUX_HEADER
            Array.Copy(BitConverter.GetBytes(auxHeader.Size), 0, returnByte, index, sizeof(ushort));
            index += sizeof(ushort);
            returnByte[index] = auxHeader.Version;
            index++;
            returnByte[index] = auxHeader.Type;
            index++;

            Array.Copy(rgbAuxInPayload, 0, returnByte, index, rgbAuxInPayload.Length);

            return returnByte;
        }