Service Dependancy for a WorkItem?

Topics: CAB & Smart Client Software Factory
Sep 5, 2006 at 7:19 AM
originally posted by: Jrad

In the CAB samples, I see the following in stage 4 of the WalkThrough:-

ServiceDependency
public WorkItem ParentWorkItem
{
set { parentWorkItem = value; }
}

In other examples I see Root substituted for Parent/parent, or the local variable is just called "workItem".

My question is, how does CAB know this should be the Parent?

Is it always the parent, independent of name. So I could write
public WorkItem FooBarWorkItem
and it would still be the parent.

If so, then a WorkItem can only be dependent on one parent WorkItem when using ServiceDependanc attribute?

Thanks
Sep 5, 2006 at 9:52 AM
originally posted by: mamu300B

Hi!

>>Is it always the parent, independent of name. So I could write "public WorkItem FooBarWorkItem" and it would still be the parent.

Yes, that's how it works.
You will always get injected, what the ObjectBuilder will find under the WorkItem key which is usually your parent.

>>If so, then a WorkItem can only be dependent on one parent WorkItem when using ServiceDependanc attribute?

Yes, you will have only one parent WorkItem.

BUT you can specify any other WorkItem getting injected as long as you can name it. That is, you can write "Dependency(Name="MyAlreadyRunningWorkItem") and you will get the WorkItem that is registered under "MyAlreadyRunningWorkItem".

-Matthias
Sep 5, 2006 at 1:12 PM
originally posted by: Jrad

Hi,

Many thanks for the quick and very clear response.

Things are becoming a little clearer...
(I hope!)

John