Ejemplo n.º 1
0
        /// <summary>
        /// transforms the data to bytes according to the selected format option
        /// </summary>
        /// <param name="format">The format option to use for byte extraction</param>
        /// <param name="data">The data to extract the bytes from</param>
        /// <returns>the extracted bytes</returns>
        private byte[] GetBytesAccordingToFormatSelected(Format format, string data)
        {
            byte[] bytes = null;
            switch (format)
            {
            case Format.File:
                bytes = ByteConvert.FileToBytes(data);
                break;

            case Format.Text:
                bytes = ByteConvert.StringToAsciiBytes(data);
                break;

            case Format.Hex:
                bytes = ByteConvert.HexStringToBytes(data);
                break;

            default:
                Debugger.Break();
                break;
            }
            return(bytes);
        }