I have multiple instances of methods in classes that I need to invoke and write quickly without adding them to my main function. How would that be completed with an attribute?
e.g. I have a lot of different classes that have a method called 'invoke'. I want to add a custom attribute that I can add to this method and then call the invoke method on each one of these classes in a different method called 'invoke all'.
Something like looks like this, but functional.
public class main_class
{
public void invoke_all()
{
// call all the invokes
}
}
public class test1
{
[invoke]
public void invoke()
{
Console.WriteLine("test1 invoked");
}
}
public class test2
{
[invoke]
public void invoke()
{
Console.WriteLine("test2 invoked");
}
}