Dependency injecting into WorkItem State

Topics: CAB & Smart Client Software Factory
Mar 14, 2006 at 11:49 AM
originally posted by: RossNeilson

I'm having a problem with dependency injection and the State property of the WorkItem class. I would like to inject an object into the State of the WorkItem, however when the ObjectBuilder attempts to do this the State is null, because it hasn't yet been created. The WorkItem is defined as follows-

public class EditPersonWorkItem : WorkItem
Dependency(CreateType=typeof(ArrayList), Name="Dummy", NotPresentBehavior=NotPresentBehavior.CreateNew)
public ArrayList Dummy
get { return (ArrayList)this.State"Dummy"; }
set { this.State"Dummy" = value; }

and the code to create the WorkItem is-


the above code is called from an event handler in the shell.

It seems to me that the State isn't created until after the ObjectBuilder has processed all the Dependency attributes. If anyone has any suggestions as to how you can inject into the State I'd be pleased to hear from them.
Mar 14, 2006 at 4:19 PM
originally posted by: marianoszklanny

Hi, as you said the state bag is not yet initialized during the properties injection strategy of the ObjectBuilder.
I posted in my blog some information about injecting state into work items, please check these for more information and ideas:

CAB: Injecting State into Child Work Items

CAB: Injecting State into Child Work Items through Custom Attribute

Mariano Szklanny