This post originated from an RSS feed registered with .NET Buzz
by Brad Wilson.
Original Post: CAB, June to October: The Big Changes to WorkItem
Feed Title: The .NET Guy
Feed URL: /error.aspx?aspxerrorpath=/dotnetguy/Rss.aspx
Feed Description: A personal blog about technology in general, .NET in specific, and when all else fails, the real world.
WorkItem is a core class, and underwent quite a few changes between the June CTP and the October CTP.
The most obvious change is that the collection-like behavior is not present on the WorkItem itself any more. Components (which we'd prefer to call Items now) are available in a collection class property called Items, and services are available in a collection class property called Services. This means calls like:
myWorkItem.Add(...);
become:
myWorkItem.Items.Add(...);
And calls like:
myWorkItem.AddService(...);
become:
myWorkItem.Services.Add(...);
In addition to these two core collection classes, there are a number of fascade classes that filter these collections. For example, to find just the IWorkspace classes in a WorkItem, you can use myWorkItem.Workspaces.
We also renamed "Create", because it wasn't quite clear what it did. The new name is "AddNew", which lets you know what the WorkItem is making a new one and adding it. The AddNew method is available on both Items and Services.
As before, you can inject services with the [ServiceDependency] attribute, and items with the [ComponentDependency] attribute.
We've added a new attribute called [CreateNew], which indicates that during injection, you'd always like a new one of the thing created. This attribute is a more general purpose form of (and replaces the) [Controller] attribute. This attribute helps write MVC/MVP style applications much easier by automatically allocating a controller or presenter as necessary.