wwDotNetBridge::ConvertToDotNetValue

Converts a FoxPro value of an 'unsupported' type to a .NET type by either using a FoxPro CAST() or converting the object into a wwDotnetBridge .NET ComValue object.

Why do we need this?

FoxPro types are fairly limited and there isn't the same variety of types as there are in .NET. For this reason some .NET types cannot be directly converted into .NET types. This method helps with the conversion process by either applying a FoxPro CAST() on the types that support it, or by creating a wwDotnetBridge .NET ComValue() object that returns the wrapped .NET type. The ComValue structure can then be used to pass a parameter or set a value on a .NET object using InvokeMethod() or SetProperty().

Example:

loType = loBridge.CreateInstance("Westwind.WebConnection.TypePassingTests")

*** Do explicit type conversion for InvokeMethod calls
loval = loBridge.ConvertToDotnetValue(16,"int16")

*** Call method with Int16 parameter
? loBridge.Invokemethod(loType,"PassInt16",loVal)

Supported Conversions (* denotes returned as ComValue object):

  • Int16, Int64
  • Byte
  • Char (1 char string or integer)
  • DbNull
  • Decimal (not required CAST( as Currency) works as well)
  • Binary (not required CAST( as Blob) works as well)
  • Byte
o.ConvertToDotNetValue(lvValue, lcType)

Parameters

lvValue
The value to convert

lcType
The type to convert to (see list above)


See also:

Class wwDotNetBridge

© West Wind Technologies, 1996-2024 • Updated: 12/10/15
Comment or report problem with topic