/// <summary>
        /// Compose the 3 items (CUSTOMVARS, OPTIONS and INPUTDATA) of the Conversion operation.
        /// </summary>
        /// <param name="expression">The data or expression to convert. May include MV marks (value delimiters), in which case the conversion will execute in each value obeying the original MV mark.</param>
        /// <param name="code">The conversion code. Must obey the Database conversions specifications.</param>
        /// <param name="conversionOptions">Indicates the conversion type, input or output: INPUT=ICONV(); OUTPUT=OCONV()</param>
        /// <param name="customVars">Free text sent to the database allows management of additional behaviours in SUB.LK.MAIN.CONTROL.CUSTOM, which is called when this parameter is set.</param>
        /// <returns>A string ready to be used in Linkar.ExecuteDirectOperation and Linkar.ExecutePersistentOperation.</returns>
        public static string GetConversionArgs(string expression, string code, CONVERSION_TYPE conversionOptions, string customVars)
        {
            string options   = (conversionOptions == CONVERSION_TYPE.INPUT ? "I" : "O");
            string inputData = code + ASCII_Chars.FS_str + expression;

            string cmdArgs = customVars + ASCII_Chars.US_str + options + ASCII_Chars.US_str + inputData;

            return(cmdArgs);
        }
        /// <summary>
        /// Returns the result of executing ICONV() or OCONV() functions from a expression list in the Database, ina asynchronous way with XML output format.
        /// </summary>
        /// <param name="conversionType">Indicates the conversion type, input or output: INPUT=ICONV(); OUTPUT=OCONV()</param>
        /// <param name="expression">The data or expression to convert. May include MV marks (value delimiters), in which case the conversion will execute in each value obeying the original MV mark.</param>
        /// <param name="code">The conversion code. Must obey the Database conversions specifications.</param>
        /// <param name="customVars">Free text sent to the database allows management of additional behaviours in SUB.LK.MAIN.CONTROL.CUSTOM, which is called when this parameter is set.</param>
        /// <param name="receiveTimeout">Maximum time in seconds that the client will wait for a response from the server. Default = 0 to wait indefinitely.</param>
        /// <returns>The results of the operation.</returns>
        public Task <string> ConversionAsync(CONVERSION_TYPE conversionType, string expression, string code, string customVars = "", int receiveTimeout = 0)
        {
            var task = new Task <string>(() =>
            {
                return(this.Conversion(conversionType, expression, code, customVars, receiveTimeout));;
            });

            task.Start();
            return(task);
        }
        /// <summary>
        /// Returns the result of executing ICONV() or OCONV() functions from a expression list in the Database, synchronously only.
        /// </summary>
        /// <param name="conversionType">Indicates the conversion type, input or output: INPUT=ICONV(); OUTPUT=OCONV()</param>
        /// <param name="expression">The data or expression to convert. May include MV marks (value delimiters), in which case the conversion will execute in each value obeying the original MV mark.</param>
        /// <param name="code">The conversion code. Must obey the Database conversions specifications.</param>
        /// <param name="outputFormat">Indicates in what format you want to receive the data resulting from the operation: MV, XML or JSON.</param>
        /// <param name="customVars">Free text sent to the database allows management of additional behaviours in SUB.LK.MAIN.CONTROL.CUSTOM, which is called when this parameter is set.</param>
        /// <param name="receiveTimeout">Maximum time in seconds that the client will wait for a response from the server. Default = 0 to wait indefinitely.</param>
        /// <returns>The results of the operation.</returns>
        public string Conversion(CONVERSION_TYPE conversionType, string expression, string code, DATAFORMAT_TYPE outputFormat = DATAFORMAT_TYPE.MV, string customVars = "", int receiveTimeout = 0)
        {
            string conversionArgs   = OperationArguments.GetConversionArgs(expression, code, conversionType, customVars);
            byte   opCode           = (byte)OPERATION_CODE.CONVERSION;
            byte   byteInputFormat  = (byte)DATAFORMAT_TYPE.MV;
            byte   byteOutputFormat = (byte)outputFormat;
            string connectionInfo   = this._ConnectionInfo.ToString();
            string result           = Linkar.ExecutePersistentOperation(this._ConnectionInfo, opCode, conversionArgs, byteInputFormat, byteOutputFormat, receiveTimeout);

            return(result);
        }
        /// <summary>
        /// Returns the result of executing ICONV() or OCONV() functions from a expression list in the Database, synchronously only.
        /// </summary>
        /// <param name="credentialOptions">Object with data necessary to access the Linkar Server: Username, Password, EntryPoint, Language, FreeText.</param>
        /// <param name="conversionType">Indicates the conversion type, input or output: INPUT=ICONV(); OUTPUT=OCONV()</param>
        /// <param name="expression">The data or expression to convert. May include MV marks (value delimiters), in which case the conversion will execute in each value obeying the original MV mark.</param>
        /// <param name="code">The conversion code. Must obey the Database conversions specifications.</param>
        /// <param name="outputFormat">Indicates in what format you want to receive the data resulting from the operation: MV, XML or JSON.</param>
        /// <param name="customVars">Free text sent to the database allows management of additional behaviours in SUB.LK.MAIN.CONTROL.CUSTOM, which is called when this parameter is set.</param>
        /// <param name="receiveTimeout">Maximum time in seconds that the client will wait for a response from the server. Default = 0 to wait indefinitely.</param>
        /// <returns>The results of the operation.</returns>
        public static string Conversion(CredentialOptions credentialOptions, string expression, string code, CONVERSION_TYPE conversionType,
                                        DATAFORMAT_TYPE outputFormat = DATAFORMAT_TYPE.MV,
                                        string customVars            = "", int receiveTimeout = 0)
        {
            string conversionArgs   = OperationArguments.GetConversionArgs(expression, code, conversionType, customVars);
            byte   opCode           = (byte)OPERATION_CODE.CONVERSION;
            byte   byteInputFormat  = (byte)DATAFORMAT_TYPE.MV;
            byte   byteOutputFormat = (byte)outputFormat;
            string result           = Linkar.ExecuteDirectOperation(credentialOptions, opCode, conversionArgs, byteInputFormat, byteOutputFormat, receiveTimeout);

            return(result);
        }