Node Factory simple example

Hey devvvvs and vuxens

Is there any simple example of how to create a node factory?

e.g. I’ve got a function that can enumerate nodes i want to create, and a general class that can act as all of the nodes. Each node would be an instance of that class with different parameters (e.g. in the constructor it defines which type of node it should act as).

Thankyou!

+1… no text …

is the plugin factory too complex?
for starters, you need to implement the IAddonFactory interface, put a “[Export(typeof(IAddonFactory))” above your custom factory and put the dll to the lib\factories folder.
this should get your constructor called.
in order to do something useful you’ll probably need the INodeInfoFactory, you get that one by importing it via your constructor for example (don’t forget to place the ImportingConstructor attribute above your constructor, or MEF will fail to compose your class).
you’d now enumerate your nodes and create a node info (via the factory) for each of those nodes. when the user later selects a node from the nodebrowser the associated node info will get handed back to all the node factories by calling CreateNode. you’ll also note that this call will provide you with an INode object. what kind of object this one is exactly depends a little on the NodeType property of the given node info, but in your case you set the NodeType to plugin so you can safely cast the INode object to IPluginHost2 (like it is done by the plugin factory).
if you look at the plugin factory it will create a little wrapper class called PluginContainer now, you’ll probably want to do something similiar.

also, the node factories are all on github, you can get some inspiration there…
https://github.com/vvvv/vvvv-sdk/tree/develop/vvvv45/src/core/Hosting/Factories

What is v4x?

if you knew we’d have to eliminate you…

@joreg: Aha ;)