I have a feeling that I am not considering this issue from a right angle here, and I just do not think about another solution.
Assuming this general class:
public abstract class Port<T> { public delegate T PullDelegate(); private PullDelegate pull; public Port(PullDelegate pull) { this.pull = pull; } public T Pull() { return pull(); } }
It is used to define "ports" in the graph-node editor. A port can pass an object / value from one node to another, but they must also be "type safe", which means that I cannot connect any port to another wrong type (at least not without some conversion).
node "owns" the port and gives it a delegate in relation to one of its methods, so when the other node "pulls" on the value, the port simply calls it and returns the correct value.
My problem starts when I try to call Pull() from a non-generic set. Obviously, I could not create a generic base method, but then Pull could not return T , it would need to return object .
In addition, each node has collectors for its ports so that other elements can receive them. This collection should not be general, since node can have many large ports.
public abstract Port[] Inputs { get; } public abstract Port[] Outputs { get; } public abstract Port[] Entries { get; } public abstract Port[] Exits { get; }
At the moment when a non-generic type comes into play, all generic types become inaccessible. If only Port<>[] would be something.
It seems to me that I missed something ...
source share