Services and Controllers

Topics: CAB & Smart Client Software Factory
Aug 21, 2007 at 11:43 PM
What is the exact difference between a CAB Service and a Controller for the MVC pattern? What code do I put into my service and what do I put into the Controller?

Also, does a Service have access to the WorkItem state? I am not having any success injecting an instance of the WorkItem state into my Service.

Any comments or ideas?

TIA?

Klaus
Aug 22, 2007 at 8:08 PM
Hi Klaus!


What is the exact difference between a CAB Service and a Controller for the MVC pattern? What code do I put into my service and what do I put into the Controller?


I’d suggest you to read the white paper Designing Smart Clients Based on CAB and SCSF.
There you will find the definitions that might help clear up your questions.


Controller is a class that implements the logic for modifying a model. One controller can modify a model presented by many views. Origin: Model-View-Controller

Services encapsulate functionality that is common for the whole client application, for a specific module, or just for WorkItems within a certain hierarchy of WorkItems (for example, for sub-WorkItems of a specific parent WorkItem). Typical services are security services responsible for authentication or authorization or Web service agents encapsulating service communication and offline capability.


Also, you can read the following topic from SCSF’s documentation:
  • Developing with the MVC Pattern (Inspecting the Software Factory Assets -> Composite UI Application Block -> Developing Applications Using the Composite UI Application Block -> Developing with the MVC Pattern)


Also, does a Service have access to the WorkItem state? I am not having any success injecting an instance of the WorkItem state into my Service.


Maybe, you can try inject a workitem into your service with ServiceDependency and get the workitem state:

private WorkItem _MyWorkItem;
[ServiceDependency]
public WorkItem MyWorkItem
{
         get
         {
                  return _MyWorkItem;
         }
         set
         {
                  _MyWorkItem = value;
         }
}

Hope it helps!

Sebastian Iacomuzzi
http://staff.southworks.net/blogs/siacomuzzi