WorkItem Service

Topics: Mobile Client Software Factory
Jun 28, 2006 at 11:45 PM
originally posted by: larsandreas

I have a question regarding the use of WorkItem service dependencies. For instance:
public LauncherView(ServiceDependency WorkItem workItem)

Does this mean there is some kind of "hidden" service providing WorkItem instances? What if there is several WorkItems available? I assume ObjectBuilder instanciates/uses an existing instance when creating the LauncherView-instance in the example above. There are plenty of examples of its use elsewhere, but I can't seem to find an explaination of what really happens "behind the curtains".

Thanks
Jun 28, 2006 at 11:59 PM
originally posted by: donelodes

I have a similar question,
For example, in the reference implementation, this is how the AuthenticationService is used:

ServiceDependency
public IMobileAuthenticationService AuthenticationService
{
set { authenticationService = value; }
}

What happens if there are more classes that implement the IMobileAuthenticationService Interface?
How does the ObjectBuilder knows wich one to inject?

Thanks in advance
Jun 29, 2006 at 6:15 AM
originally posted by: dcazzulino

Location of services is done by looking at the owning WorkItem.Services collection. Unless an object is registered as a service, it will not be on that list, so the fact that many objects in the work item implement the interface doesn't matter. And if you try to register the same service interface more than once, you will get a runtime exception. Effectively, the type of the service is the key in that collection.

Also, requests for services bubble up the work item containment hierarchy, so they go all the way up to the root work item. That's why you only need to register the service at the root if you want to (such as with the authentication service.

HTH
Jul 1, 2006 at 10:20 AM
originally posted by: m_a_madero

larsandres:

About the WI, it will take the workItem in which that item is built.
Jul 3, 2006 at 10:38 PM
originally posted by: donelodes

But why ServiceDependency and not Dependency? Is a WorkItem considered a Service?
Jul 4, 2006 at 12:14 AM
originally posted by: larsandreas

Hi.
Another question regarding WorkItems and the attributes available. I have the following instancitation code for a SmartPart:

MyView view = this.Items.AddNew<MyView>();

The MyView class has a ServiceDependency attribute on a WorkItem property to let ObjectBuilder inject the relevant WorkItem instance:

WorkItem parent;
ServiceDependency
WorkItem ParentWorkItem
{
set { parent = value; }
}

The problem, however, is that the set method on the property is never called. I've tried the Dependency attribute as well, not knowing the appropriate situations to use them.

An explaination of when to use the different attributes, and an explaination of why the property set-method is never called will be appreciated.

Thanks

Lars Andreas
Jul 5, 2006 at 12:44 AM
originally posted by: larsandreas

Hi.

I found the mistake. The property needs to be public. Thats it :) But I still hope the different attributes will be explained, though.


Lars Andreas