wwDotNetBridge.CreateInstanceOnType

Allows creation of a new .NET type and assigning that type to a .NET object property without ever going through Visual FoxPro. This allows for creation on non-COM visible types in .NET and indirect manipulation of them.

o.CreateInstanceOnType(loInstance,lcProperty,
        lcClass,lvParm1,lvParm2,
        lvParm3, lvParm4, lvParm5)

Return Value

.T. or .F.

Parameters

loInstance
The instance of the .NET object that the new object will be attached to

lcProperty
The property of the .NET object that the new object will be attached to

lcClass
The full .NET typename of the class that will be instantiated and assigned

lvParm1-3
Up to three constructor parameters for the .NET type instantiated.

Remarks

This method is limited to 5 parameters on the .NET constructor called.

Example

Do ServiceProxy
loProxy = CREATEOBJECT("ServiceProxy")

*** wwDotNet instance
LOCAL loBridge as wwDotNetBridge
loBridge = loProxy.oBridge

*** .NET Object instance
LOCAL loService as Service.TaxService
loService = loProxy.oService

*** TaxService CredentialSoapHeader is marked [ComVisible(false)] in .NET
*** so it can't be passed to VFP. Instead create the type 
*** entirely in .NET  (loService.CredentialSoapHeaderValue)
? loBridge.CreateInstanceOnType(loService,"CredentialSoapHeaderValue",
                                "Service.CredentialSoapHeader")

*** Must manipulate the object indirectly through .NET using
*** Set/GetPropertyEx methods.
loBridge.SetPropertyEx(loService,"CredentialSoapHeaderValue.Username","me")
loBridge.SetPropertyEx(loService,"CredentialSoapHeaderValue.Password","secret")

result = loProxy.HelloWorld()
? result
? loProxy.cErrorMsg

See also:

Class wwDotNetBridge

© West Wind Technologies, 2023 • Updated: 06/30/20
Comment or report problem with topic