scsf

In SCSF/CAB Can I ask the framework for the workitem containing "this" smartpart?


I'm looking for something like:

WorkItem item = CompositeUI...GiveMeTheWorkItem(this);

The code I've inherited is injecting the root workitem into everything which seems a bit long winded.


Solution

  • figured I might as well try answering this as well for you. Based on my experience, I would have to say that what you are describing above is not available in the base CAB/SCSF framework.

    The RootWorkItem contains a collection of child WorkItems which are created by your application to handle specific use case scenario. Each WorkItem contains a collection of smart parts and you can check if a WorkItem contains a specific SmartPart using the Get or Contains methods exposed by the WorkItem.SmartPart collection.

    While I agree with you that injecting the RootWorkItem into everything is a bit "long winded", if you use the WorkItemController base class for your WorkItems (which you should) then this is done for you in the base class.

    As a possible solution, you could extend the WorkItemController base class with some sort of a FindSmartPart method which could traverse through the WorkItem collection of the RootWorkItem class and search for the SmartPart using the above mentioned methods.

    Hope that helps.