Multiple View instances vs. UIExtensionSite constants?

Topics: CAB & Smart Client Software Factory
Oct 11, 2007 at 2:45 PM
I have this scenario. I created a SmartPart, which registers on its OnLoad method some UIExtensionSite with a constant name (following SCSF practices).
This SmartPart is a utility for the Shell, so it is instanced when the shell starts, and is contained on the ShellWorkItem.
Then i needed to use that SmartPart functionality on other place (showing it as a modal dialog). The problem is that when i instance that view again (adding it to other new workitem, not the shell) as the SmartPart tries to register the it's UIExtensionSite, with the same constant name, CAB throws the exception of duplicate UIExtensionSite names.
The UIExtensionSite is a menu provided on the SmartPart, so at future it could be extended by other modules.
My question is how can i solve that problem doing it with some "best practice"?
I thought that registering the UIExtensionSite with a combination of WorkItem.ID + constant name would solve the duplicate name, but then the "constant name"of the UIExtensionSite is no more a constant, but a combination of 2 values. So with that solution i would lose the advantages of other modules extending the "unique published name of the UIExtensionSite", because that constant name is useless if that module does not know how to "combine" that name with "other things (as WorkItem.ID) to extend that site.

Hope i make myself understood. Any advice on that problem? Thank you!
Oct 11, 2007 at 3:18 PM
I'm no expert in SCSF, but i can think of one thing -
You can write a service called "WorkItemLocatorService" with a method like this:
public WorkItem FindContainingWorkItem(WorkItem workItem, object smartPart)
that searches recursively in a workitem and all its children for a smartpart, and that way you'd know what the UIExtensionSite's name is.
Still breaks the constant preservation goal, but i didn't see another solution with this design, which i liked btw.