calling an optional module

Topics: Web Client Software Factory
Feb 9, 2009 at 7:43 PM
Hi all,

I'd like to get some opinions on the best approach to conditionally expose certain functionality only when the module is present (let's say a link on the home page).

Here's the exact scenario we are facing. We have the "main" app and we have a SynchronizationServices module. If the app is installed on the intranet, then sync services module is NOT installed and synchronization functionality should not be available. The alternative configuration is when the app is on a laptop and the sync services module is present.

Thanks to everybody

Feb 9, 2009 at 8:22 PM
Is this how it's supposed to be done:

1. None of the other modules should have a reference to the optional module.
2. The optional module should register its "menu" items with the ISiteMapBuilderService
3.a. On machines that need the optional module, its assembly will be copied to the Bin folder of the website, <module> entry will be added to the web.config file.
Feb 9, 2009 at 8:27 PM
I guess where I get lost is the fact that our Sync Services module is a foundational modula that doesn't have .ASPX and I am not sure how it can register with the ISiteMapBuilderService (or equivalent mechanism).

Feb 11, 2009 at 12:25 PM
Edited Feb 11, 2009 at 12:26 PM


I agree with your approach to solve the requirement. You should add a link in the SiteMap only if the module is loaded in the application (The best way to do that is in the ModuleController).

You shouldn’t have problems registering nodes in the SiteMap from a Foundational Modules, you can get as a template the RegisterSiteMapInformation method inside a Business Modules’ ModuleController class. The only thing that you should take into account is the link that the node points to, must be a valid virtual path, in other words, this must point to a page inside the application.


What do you expect to happen if the user clicks the link in the SiteMap? If there should be a UI for that, you may need to have a Business Module instead.


Where are you hosting the “synchronization” logic? Are you deciding use a Foundation Module because it only contains Services?

If this is the case, you may want to inject into your other modules with a service dependency, but specifying that the service is not required, as shown in the following code:


                 public MyMainModuleController([ServiceDependency(Required = false)] IMySynchronizationService syncService)


                                If (syncService != null)


                                                // the module is loaded and thus registered the service.




Please, let me know if this helps.


Ezequiel Sculli

Feb 11, 2009 at 1:01 PM
Thank you, Ezequiel,

I was injecting the sync module, but did not know about the (Required=false) property.
I ended up creating an alternate Sync foundational module that compiles into assembly with the same name as the original sync module.
The Sync service interface exposes bool CanDoSync and the alternate module simply returns CanDoSync=false.
The consuming logic enables sync functionality based on what CanDoSync.
This way I can choose which of the two ISyncService implementations to deploy.

(No, no UI for the sync process - the most, a message returned and maybe a few events exposed in a later version.)