I have an abstract class as follows:
public abstract class Node
{
public abstract void run();
}
There are some child nodes that may have several properties as input and output. But all the operation is done just in run()
method that each Node should implement. For example a Node that draws a line could be something like this:
public class LineNode : Node
{
[Input]
public Point a;
[Input]
public Point b;
[Output]
public Line line;
public override void run()
{
line = new Line(a, b);
// draw line ...
}
}
[AttributeUsage(AttributeTargets.Field)]
public class Input : System.Attribute
{
}
[AttributeUsage(AttributeTargets.Field)]
public class Output : System.Attribute
{
}
As you see I don't have any prior information about fields in the child classes. ** For a Node to be a valid node in convention, It is just required to have at least one output.** I want to force all other users to have at least one output in their Nodes so I can find it by reflection by looking for a field that [Output] attribute is applied to.
Is this possible?
Thanks for any help
Aucun commentaire:
Enregistrer un commentaire