Smart part from another module

Topics: CAB & Smart Client Software Factory
Mar 30, 2006 at 9:34 PM
originally posted by: mojsony

Hi all,

I need help on fillowing...

Assume I have 2 modules "Statement Managament", and "Report Center".
I want to display Smart Part from "Report center" module (Smart part wher I can choose already defined statement reports) in SingleStatementView (located in "Statement managament" module).

So, if decide that one should not have report center that smart part will not be displayed.

Any code samples would be nice ..

Thanks,

Sale
Mar 30, 2006 at 11:10 PM
originally posted by: davidlaribee

This code should allow you to determine if a specific module is loaded at run time. This would live from whatever workitem, your shell, etc... (it assumes RootWorkItem exists as a property of the object that contains this code).

IModuleLoaderService moduleLoaderService =
RootWorkItem.Services.Get&ltIModuleLoaderService&gt();

bool userHasReportCenter = false;

foreach (LoadedModuleInfo moduleInfo in moduleLoaderService.LoadedModules)
{
if (moduleInfo.Name == "ReportCenter")
{
userHasReportCenter = true;
break;
}
}

This assumes you've added the "ModuleAttribute" in your module's AssemblyInfo (otherwise you will need to use as standard, fully qualified assembly name), e.g.:

assembly: Microsoft.Practices.CompositeUI.Module("ReportCenter")

You could also use IWorkItemTypeCatalogService with a specialized interface... this might give you a less imperative and more "plugin-based" approach if that's important to you. Check out the BankTeller sample app's IShowInWorkspace for an example of how to set this up.
Apr 1, 2006 at 4:20 AM
originally posted by: mojsony

Thanks,

Your post was usefull in determination of module existance.

More "plugin-based" approach is exactly what I need.

If you (or someone has code example) for use of IWorkItemTypeCatalogService

"if you want to show SmartPart from another module, SmartPart need to be in RootWorkItem."
Is this correct?

Sale.
Apr 6, 2006 at 1:58 PM
originally posted by: davidlaribee

See this thread:

http://www.gotdotnet.com/codegallery/messageBoard/Thread.aspx?id=22f72167-af95-44ce-a6ca-f2eafbf2653c&mbid=c09776ca-f94c-4c83-a80c-75d381cabdd6&threadid=f55a65ee-692d-4810-af1c-6ba2330b665c
Apr 6, 2006 at 10:14 PM
originally posted by: mojsony

Thanks a lot

Thats it.

Sale