I'm wondering if there is an equivalent function to PHP's call_user_func()
in ASP.NET application. I'm looking to do a conversion from a PHP application to ASP.NET as a means of teaching myself the language, by taking a CMS I built professionally and trying to recreate it in this other language.
The reason I need a function similar to this, is because the current structure of my PHP CMS involves a plugin architecture, and specific parts of the CMS expose themselves for the plugins, and it then handles the returned information as an array. It's pretty much the same system Drupal uses.
Am I perhaps on the wrong track with this?
I think for clarification I should provide an example of how this works in my current system:
<?php
class Test {
function TestMessage() {
// set up array
$arrTest = array("Hello", "World");
// get extra values from all available plugins
$arrExtras = CMS::InvokeHook("HelloTest");
// now contains Hello, World, Foo, Bar
$arrTests = array_merge($arrTest, $arrExtras);
}
}
class CMS {
InvokeHook($function) {
// now contains a couple plugins
$plugins = CMS::GetPlugins();
// empty array of values
$values = array();
foreach($plugins as $plugin) {
// if this plugin has the called method...
if(method_exists($plugin, $function)) {
// call the function and merge in the results
$values[] = call_user_func(array($plugin, $function));
}
}
// return results as an array
return $values;
}
}
class FooTest {
function HelloTest() {
return "Foo";
}
}
class BarTest {
function HelloTest() {
return "Bar";
}
}
?>
NOTE: The InvokeHook() call is simplified as I'm writing this from memory, but that is the gist of it.