VFP and .NET Interop
Assigning Values to a .Net Property via wwDotNetBridge
Gravatar is a globally recognized avatar based on your email address. Assigning Values to a .Net Property via wwDotNetBridge
  Chad Newman
  All
  Feb 21, 2017 @ 10:30am

I'm trying to set a .net property using the wwDotnetbridge. The property is a list with a list of Last Names. The sample .net code is:

parser.CustomMultiWordLastNames = new List<string>()
    {"TALKS DIFFERENT",
    "IRON BEAR",
    "RUNS THROUGH"
    }

How would I set the same property using VFP and the wwDotNetBridge? I'm working the .net DLL directly.

Thanks,

Chad Newman Black Mountain Software

Gravatar is a globally recognized avatar based on your email address. re: Assigning Values to a .Net Property via wwDotNetBridge
  Rick Strahl
  Chad Newman
  Feb 21, 2017 @ 01:53pm

Unforuntatey this is one of the few things you can't do: Create generic types.

The problem is that generic types are a language compilation feature and the compiler constructs these types into concrete types at runtime.

There are some ways to do this inside of .NET but even they are ugly and I'm not sure how to turn that into something that can be generically accessed (ie. without having a hard coded type to start from):

So for this the answer unfortunately is: You need a .NET wrapper that creates the type for you.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: Assigning Values to a .Net Property via wwDotNetBridge
  Chad Newman
  Chad Newman
  Feb 21, 2017 @ 02:26pm

Rick, Thanks much for the answer! I will work in another direction.

Thanks,

Chad

Gravatar is a globally recognized avatar based on your email address. re: Assigning Values to a .Net Property via wwDotNetBridge
  Rick Strahl
  Chad Newman
  Feb 21, 2017 @ 04:18pm

I'm going to take a look and see if there's a way to do this, but looking over that old article I don't think it'll be because AFAIK there's no way to get a generic type reference without hardcoding the generic base type.

I have code in Html Help Builder that does all sorts of crazy stuff in getting references to types and that might help, but it's a different scenario where the types already exist.

FWIW, you can access the generic type AFTER it's been instantiated fine. That should work without too much effort. But there are limitations there too if the methods take generic type parameters that can't be inferred. InvokeMethod() has all sorts of magic to make most scenarios work however.

+++ Rick ---

© 1996-2024