Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP to ASP.NET - call_user_func() equivalent?
    primarykey
    data
    text
    <p>I'm wondering if there is an equivalent function to PHP's <code>call_user_func()</code> 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.</p> <p>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.</p> <p>Am I perhaps on the wrong track with this?</p> <p>I think for clarification I should provide an example of how this works in my current system:</p> <pre><code>&lt;?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"; } } ?&gt; </code></pre> <p>NOTE: The InvokeHook() call is simplified as I'm writing this from memory, but that is the gist of it.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload