Forum

Pin allowing both objects and interfaces

so I do this:

[Input("Foobar")](Input("Foobar"))
public ISpread<object> FInput;

which accepts classes fine but not interfaces. So in case of a DX11 stuff FloatRenderSemantic is OK, but when it’s presented as its inheriting interface IDX11RenderSemantic it’s a no-go. (please note this type is only chosen for an example, I also want to use other stuffs which are represented as interfaces) as far as I know, one can absolutely do this in C#:

IDX11RenderSemantic myvar = new FloatRenderSemantic();
object myobj = myvar as object;
DoSomethingWithIDX11RenderSemantic(myobj as IDX11RenderSemantic);

So why vvvv won’t allow me to do that? or I may not know something basic about upcasting from interfaces to the .NET base object. In that case does anyone has an advice for it?

also somewhat related. I’m trying to overcome above problem with what I found “IPluginHost2.CreateNodeInput(…)” something like this:

INodeIn Input;
public void OnImportsSatisfied()
{
    FPluginHost.CreateNodeInput("Input", TSliceMode.Dynamic, TPinVisibility.True, out Input);
}

what should I have to do if I want the resulting pin to behave like the pins in the “Node” category? In other words accept any type. Because currently it only accepts connections from “empty” node pins like from “GetSlice (Node)” or the node IOBox. And if I connect something through those it works just fine. TBH I only need to accept any kind of .NET types including interfaces, I don’t care about those nasty delphi remnants from the past.

nailed it I had to add

Input.SetSubType2(new Guid[]() { }, "Variant");

jeez
now this is plugininterface v1 as i can understand. still would be nice to have a v2 only solution

did you try the alpha?

hmm i haven’t checked that out until now, nice improvement! I still have to use INodeIn but I can get rid of my AsWeakObject nodes for primitive types!

hi microdee,

your initial question. this feels like a bug - i’ll do more investigation.
your second one. Yeah please have a try of the new feature that the old INodeIn offers as woei mentioned and report back. thanks!