IValueConverter.Convert

Fore Syntax

Convert(Value: Variant): Variant;

Fore.NET Syntax

Convert(Value: object): object;

Parameters

Value. Converted value.

Description

The Convert method converts the specified value.

Comments

Type of the value obtained after conversion must be determined in the IValueConverter.DataType property.

Fore Example

The example is given for the custom class that rounds real values.

Add links to the Cubes, Dal and MathFin system assemblies.

// Class that converts values
Class Converter: Object, IValueConverter
    
    // Value conversion function
    Public Function Convert(Value: Variant): Variant;
    Begin
        // Round value
        Return Math.Round(Value As Double,2);
    End Function Convert;
    
    // Return type of converted values
    Public Function get_DataType: DbDataType;
    Begin
        Return dbDataType.Float;
    End Function get_DataType;
    
    // Function for checking availability of value conversion
    Public Function TryConvert(Value: Variant; Var Result: Variant): Boolean;
    Begin
        Try
            // If conversion is available, function returns True
            Result := Convert(Value);
            Return True;
        Except
        End Try;
        // If conversion is not available, function returns False
        Return False;
    End Function TryConvert;

End Class Converter;

Fore.NET Example

The requirements and result of the Fore.NET example execution match with those in the Fore example.

Imports Prognoz.Platform.Interop.Cubes;
Imports Prognoz.Platform.Interop.Dal;
Imports Prognoz.Platform.Interop.MathFin;

// Class that transforms values
Public Class Converter: Object, IValueConverter
    
    // Value conversion function
    Public Function Convert(Value: object): object;
    Var
        Maht: MathClass;
    Begin
        // Round value
        Maht := New MathClass.Create();
        Return Maht.Round(Value As Double, 2);
    End Function Convert;
    
    // Return type of converted values
    Public Property DataType: DbDataType
    Get
    Begin
        Return dbDataType.ddtFloat;
    End Get
    End Property DataType;
    
    // Function for checking availability of value conversion
    Public Function TryConvert(Value: object; Var Result: object): Boolean;
    Begin
        Try
            // If conversion is available, function returns True
            Result := Convert(Value);
            Return True;
        Except
        End Try;
        // If conversion is not available, function returns False
        Return False;
    End Function TryConvert;

End Class Converter;

See also:

IValueConverter