Is it possible to pass a condition as parameter as you do with actions?
Here's an example.
public void Test(Action action, Condition condition);
...
Test( () => Environment.Exit(0), () => variable == variable2 );
You can pass values to the parameters that are declared in the AccessProfile widget by reference, by value, or by specifying the direct value. Define this option in the main AccessProfile. This topic provides an example of an AccessProfile widget and a main AccessProfile.
Parameter passing involves passing input parameters into a module (a function in C and a function and procedure in Pascal) and receiving output parameters back from the module. For example a quadratic equation module requires three parameters to be passed to it, these would be a, b and c.
Try passing the second argument as type Func<Boolean>
. The code should work as you have it in the second part of your question:
public void Text(Action action, Func<Boolean> condition) {
if (condition()) action();
}
EDIT: Note that what you would be doing in your usage example is creating a Closure containing the captured variables variable and variable2. You should understand the implications of closures before using them in this way.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With