Click or drag to resize

BcfFormatT Delegate

Formats values before set in Value (e.g trim strings, round decimals).

Namespace:  CalculationWorks.BusinessModel
Assembly:  CalculationWorks.BusinessModel (in CalculationWorks.BusinessModel.dll) Version: 4.2.0
Syntax
public delegate T BcfFormat<T>(
	BcfColumn<T> column,
	T proposedValue
)

Parameters

column
Type: CalculationWorks.BusinessModelBcfColumnT
The column.
proposedValue
Type: T
The input value.

Type Parameters

T
The Value-property-type.

Return Value

Type: T
Examples
Add Trimming to all String Columns
public static class SetupHelper
{
    public static void AddStringTrimming(BcfDataSetSetup setup)
    {
        foreach (var stringColumnSetup in setup.Tables.Where(t => t.Columns != null).SelectMany(t => t.Columns).OfType<BcfColumnSetup<string>>())
        {
            if (!stringColumnSetup.HasFormatter) stringColumnSetup.Formatter = StringColumnFormatter;
        }
    }
    private static string StringColumnFormatter(BcfColumn<string> column, string proposedValue)
    {
        var s = proposedValue?.Trim();
        if (column.AllowNull && s == string.Empty) return null;
        return s;
    }
}
See Also