/// <summary>
        /// Strings from provider for position.
        /// </summary>
        /// <param name="dataProvider">
        /// The data provider.
        /// </param>
        /// <param name="positionIndex">
        /// Index of the position.
        /// </param>
        /// <returns>
        /// The <see cref="string"/>.
        /// </returns>
        public string StringFromProviderForPosition(
            UPCRMListFormatterFunctionDataProvider dataProvider,
            int positionIndex)
        {
            if (positionIndex >= this._positions.Count)
            {
                return(string.Empty);
            }

            var position = this._positions[positionIndex];

            return(position?.StringFromDataProviderOptions(dataProvider, this._formatOptions) ?? string.Empty);
        }
        /// <summary>
        /// Strings from row data provider value array options.
        /// </summary>
        /// <param name="row">
        /// The row.
        /// </param>
        /// <param name="dataProvider">
        /// The data provider.
        /// </param>
        /// <param name="valueArray">
        /// The value array.
        /// </param>
        /// <param name="options">
        /// The options.
        /// </param>
        /// <returns>
        /// The <see cref="string"/>.
        /// </returns>
        public string StringFromRowDataProviderValueArrayOptions(
            UPCRMResultRow row,
            UPCRMListFormatterFunctionDataProvider dataProvider,
            List <string> valueArray,
            UPFormatOption options)
        {
            string result            = null;
            var    colSpanFieldCount = 0;
            UPConfigFieldControlField colSpanField       = null;
            List <string>             colSpanFieldValues = null;
            string combineString = null;

            foreach (var field in this._fields)
            {
                var rawColumnValue = string.Empty;
                var columnValue    = string.Empty;
                if (dataProvider != null)
                {
                    if (!string.IsNullOrEmpty(field?.Function))
                    {
                        rawColumnValue = dataProvider.RawValueForFunctionName(field.Function);
                        if (!string.IsNullOrEmpty(rawColumnValue))
                        {
                            columnValue = field.ValueFromRawValueOptions(rawColumnValue, options);
                        }
                    }
                }
                else if (valueArray != null)
                {
                    columnValue = valueArray.Count > field.TabIndependentFieldIndex
                                      ? valueArray[field.TabIndependentFieldIndex]
                                      : string.Empty;

                    rawColumnValue = columnValue;
                }
                else
                {
                    rawColumnValue = row.RawValueAtIndex(field.TabIndependentFieldIndex);
                    columnValue    = row.ValueAtIndex(field.TabIndependentFieldIndex);
                }

                bool emptyColumnValue = false;

                if (field.Field.FieldType == "F")
                {
                    if (field.Attributes.ExtendedOptionIsSetToFalse("supportsDecimals") &&
                        !string.IsNullOrWhiteSpace(rawColumnValue) &&
                        decimal.TryParse(rawColumnValue, out var value))
                    {
                        const string noDecimalPlacesFormat = "F0";
                        columnValue = value.ToString(noDecimalPlacesFormat);
                    }

                    if (string.IsNullOrEmpty(rawColumnValue) || field.Field.IsEmptyValue(rawColumnValue))
                    {
                        columnValue = !options.HasFlag(UPFormatOption.Show0Float)
                                          ? string.Empty
                                          : StringExtensions.FloatDisplayTextFromFloat(0);

                        emptyColumnValue = true;
                    }
                }
                else if (field.Field.IsNumericField)
                {
                    if (string.IsNullOrEmpty(rawColumnValue) || field.Field.IsEmptyValue(rawColumnValue))
                    {
                        columnValue = !options.HasFlag(UPFormatOption.Show0)
                                          ? string.Empty
                                          : StringExtensions.IntegerDisplayTextFromInteger(0);

                        emptyColumnValue = true;
                    }
                }
                else if (string.IsNullOrEmpty(rawColumnValue) || field.Field.IsEmptyValue(rawColumnValue))
                {
                    if (field.Field.FieldType == "B")
                    {
                        if (string.IsNullOrEmpty(columnValue) || columnValue.Equals(this.ListFormatter.DisplayNo))
                        {
                            columnValue      = string.Empty;
                            emptyColumnValue = true;
                        }
                    }
                    else
                    {
                        if (!options.HasFlag(UPFormatOption.Show0) || columnValue != "0")
                        {
                            columnValue = string.Empty;
                        }

                        emptyColumnValue = true;
                    }
                }

                var currentCombineString = field.Attributes.CombineString;
                var range = 0;
                if (!field.Attributes.NoPlaceHoldersInCombineString && !field.Attributes.CombineWithIndices &&
                    !string.IsNullOrEmpty(currentCombineString))
                {
                    range = currentCombineString.IndexOf("v", StringComparison.Ordinal);
                    if (range > 0 && !string.IsNullOrEmpty(columnValue))
                    {
                        columnValue = currentCombineString.Replace("v", columnValue);
                    }
                    else if (range == -1)
                    {
                        range = currentCombineString.IndexOf("n", StringComparison.Ordinal);
                        if (range > 0)
                        {
                            columnValue = emptyColumnValue ? string.Empty : currentCombineString.Replace("n", columnValue);
                        }
                    }
                }

                if (colSpanFieldCount > 0)
                {
                    colSpanFieldValues.Add(!string.IsNullOrEmpty(columnValue) ? columnValue : string.Empty);

                    if (--colSpanFieldCount == 0)
                    {
                        columnValue = colSpanField?.Attributes?.FormatValues(colSpanFieldValues);
                    }
                }
                else if (field.Attributes.FieldCount > 1)
                {
                    colSpanFieldCount  = field.Attributes.FieldCount - 1;
                    colSpanField       = field;
                    colSpanFieldValues = new List <string> {
                        columnValue
                    };
                }

                if (colSpanFieldCount == 0 && !string.IsNullOrEmpty(columnValue))
                {
                    if (string.IsNullOrEmpty(result))
                    {
                        result = columnValue;
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(combineString))
                        {
                            result += $"{combineString}{columnValue}";
                        }
                        else if (range > 0)
                        {
                            result += columnValue;
                        }
                        else
                        {
                            result += $" {columnValue}";
                        }
                    }

                    combineString = range <= 0 ? currentCombineString : string.Empty;
                }
            }

            return(options.HasFlag(UPFormatOption.DontRemoveLineBreak) ? result : result?.SingleLineString());
        }
 /// <summary>
 /// Strings from data provider options.
 /// </summary>
 /// <param name="dataProvider">
 /// The data provider.
 /// </param>
 /// <param name="options">
 /// The options.
 /// </param>
 /// <returns>
 /// The <see cref="string"/>.
 /// </returns>
 public string StringFromDataProviderOptions(
     UPCRMListFormatterFunctionDataProvider dataProvider,
     UPFormatOption options)
 {
     return(this.StringFromRowDataProviderValueArrayOptions(null, dataProvider, null, options));
 }