I have a PRISM desktop app which loads modules from a directory with the help of the DirectoryModuleCatalog.
Everything is fine, except that I cannot find a way to get the instance of a loaded module.
IModuleManager and IModuleCatalog don't have a method like getInstance(ModuleInfo) or similar.
See
moduleManager.LoadModule(moduleInfo.ModuleName);
This line loads the module properly(moduleManager is of type IModuleManager), but what do I have to do next to get the actual instance of this module?
The modules are loaded on demand of the user, so I cannot register all modules at startup within the bootstrapper.
If by Module instance you mean the class that implement IModule, then you must explicitly register the instance into the container to be able to get it.
Although the aforementioned will work, you should not take that approach at all. The idea is that the module classes are specific to a particular module and should only be used for module initialization purposes.
I would place each module's Start method in a separate component (IStartable), register each component in the container with a different Id and resolve/import an IEnumerable to get all instances that have the start method.
Hope this helps
Related
Please take a look at the 2 photos i attached, i wish to call the methods from one project to another. Both projects are in the same solution. I have already made the reference to the project containing the method in the project i want to call the method.
http://postimg.org/image/m42dlc28r/
http://postimg.org/image/w03gkz80r/
In your main project, go to
Project -> Add Reference
In that window, click browse and find the compiled version of your other project (Probably in the Release or Debug folder)
In your main projects window add this to the very top of your code (even above your class declaration)
Imports SecondProjectRootNamespace
That should give you enough information on how to do what your trying to do, but if anything was unclear, I am going to need all the details to provide a more precise answer.
Also, make sure your methods/functions are NOT declared as private.
Private = Method is only visible from within the same class
Friend = Method is only visible from any class within the same assembly (same .exe or .dll or etc)
Public = Method has no access restrictions
There are a few others but those are the basics
Try to find the dll file of the method that you want, then add it as reference in the properties of your application
Good afternoon,
I don't know if what I want to do is possible, so here goes.
I have a module that extends Page_Controller, but I want certain functions to be accessible via the site root.
Eg: getMyDataObjectList();
Currently, they only work if I go through the normal MVC routing structure.
I've found that when I place the function 'getMyDataObjectList' within '/mysite/code/Page.php' it works.The problem is, I don't want to place the code in there. I want it bundled with my Custom Module, but to work the same as though it was in 'mysite/code/Page.php'
[Example Scenario]
site root: http://[somesite].com
By default, the 'Page.ss' template loads.
I would like the theme developer to be able to call my module functions (API) within any template/Layout page, and have the result returned from the site root
Currently, this only works if I move the "API" functions to '/mysite/code/Page.php'
If the code is in my module, then data is only returned when you go to:
http://[somesite].com/[module_controller]
Can this be achieved? If so, how?
Thanks for your assistance.
[Update - Code Solution]
///>MyExtension.php
class MyExtension extends Extension{
public function getMyDataObjectList(){
return 'object list goes here!';
}
}//class
///>[Module] => _config.php
Object::add_extension('Page_Controller', 'MyExtension');
And as always, I do a (/dev/build?flush=1) just in case.
Thanks to: 'simon_w'
Yes, this is relatively straightforward. Simply, create an Extension subclass with your methods in them and then add that to Page_Controller. An Extension subclass is almost exactly the same as a DataExtension, they're just for classes other than DataObjects.
can anyone tell me how to call only blocktopmenu module in prestashop...if i use displayTop hook it calls various other modules along with it..but i only want to call blocktopmenu..is it possible to create an object of Blocktopmenu class and access the hookDisplayTop() of that class..so that i can avoid other modules...i tried but its not working
when i try to implement this
Call Module in tpl file in prestashop
it shows "This module cannot be transplanted to this hook."
When you call Hook::exec() you can specify a module ID in the 3rd parameter.
It would be something like that:
Hook::exec('displayTop', null, Module::getModuleIdByName('blocktopmenu'));
Regards,
Never touch the FrontController.
You have to create a new hook, then attach your module to this hook.
After that, you can call Hook::exec('your_hook').
I have in my Eclipse plugin some programmatically defined handlers (for instance cut/copy/paste) and some other editor related actions that are defined via the extension framework.
If I close the view of my plugin and reopen it the handlers defined via extension framework seems to break and when executed seems to use disposed gui elements. The programmatically one are readded in the createViewPart() Method and keep working.
I don't get how to reload the handlers defined via extension framework?
In handlers added through the extension framework, they are expected to get what then need to operate from the ExecutionEvent that's provided in the execute(*) method. org.eclipse.ui.handlers.HandlerUtil can extract most of the workbench related information for you.
Saving state in your handler between calls is not guaranteed to work, as the framework can dispose and recreate the handler as it needs to.
I am new to CAB framework. After going through the sample GPS application I understood how a single module is loaded and its view is displayed.
I have a project in which I have 3 forms. Should I create a single module with three different Views for this or should I create three different modules for this.
If I create three views, how do i Switch between these views. And if I am creating three different Modules, how do i switch between these modules.
thanks.
If you will always use these three forms together, put them in the same module. If you will need only one or two of these forms at a given time, put them in separate modules, so you can load only the forms you need on demand.
I don't understand what you exactly mean by "switch between modules". If you refer to how you select which modules to load at the application start, you do it by overriding the GetModuleCatalog method in the bootstrapper and creating a module catalog inside the overrided method. If you mean how to load modules dinamically at any point in the application, you can do that by using the LoadModule method in the container's IModuleManager object.