» VL Dynamic instancing without Delegates
This site relies heavily on Javascript. You should enable it if you want the full experience. Learn more.

VL Dynamic instancing without Delegates

demo reflection vl

about

Hi!

I was wondering how to instance an arbitrary object based on its type name in VL for a while.

For now I offer this solution that uses the built-in Deserialize functionality, inspired by the arbitrary object spread demo in the VL Serialization help patch.

Although not perfect (any object you expect to instance has to be explicitly used in the patch (inspired by elias's LINK experience)), it's the closest solution I know of until this functionality gets native support. Is it better than Delegates with a Dictionary? You decide!

Any simplification tips appreciated.

Until next time!

Elias 21/01/2019 - 17:12

Hey Dominik,
nice to put this out there. I'll report back once I get to VL and dynamic instantiation again.

microdee 22/01/2019 - 12:26

Is there a limitation of why Activator.CreateInstance wouldn't work in vl? at least it should work in script region https://docs.microsoft.com/en-us/dotnet/api/system.activator.createinstance?view=netframework-4.7.2

also for more reflection goodies check out fasterflect https://github.com/buunguyen/fasterflect ;)

Elias 23/01/2019 - 12:31

CteateInstance should also work but maybe little tricky to know what values to feed for the arguments. Would be easier if a default ctor would be present in target code.

anonymous user login

Shoutbox

~2h ago

metrowave: what happened to the list of whose logged-in/on-line (above), now only showing me and guests...

~2d ago

joreg: Don't forget: This months #vvvv meetup in #berlin is happening on the 27th: 12-berlin-vvvv-meetup

~2d ago

joreg: @u7 @CeeYaa, we're investigating this...

~2d ago

tonfilm: Under the hood: We switched from #SharpDX to #Xenko math. vl-switch-to-xenko-math VL vvvv #visualprogramming #dotnet #creativecoding

~2d ago

CeeYaa: haha it was frozen for 10 seconds when I send this Shout before - using Firefox

~2d ago

CeeYaa: hui really slow speed on MainPage, Contributions ... speed in Forum quite OK

~2d ago

u7angel: mmm, the site is really slow now.

~3d ago

joreg: PSA: and we're back!

~4d ago

joreg: PSA: Thursday night starting 11pm CET vvvv.org will move servers. If all goes well we should be back soon after.

~5d ago

joreg: But first: This Friday in Berlin: Join our full day "Getting started with Generative Design Algorithms" workshop https://nodeforum.org/announcements/workshop-getting-started-with-generative-design/