[ServiceDependency] and [CreateNew]

Topics: CAB & Smart Client Software Factory
Jan 7, 2006 at 10:04 AM
originally posted by: ovidius

I'm learning about CAB following the HOL, and because i'm Italian and i don't know English very well, i'm in difficult to understand some things.

Those attribuse are used to use a service without create an instace of it (I think!?!?).
In the lab 2 we define a controller for the view in this way:

private CustomerQueueController myController;

public CustomerQueueService MyController
{ set { mycontroller=value; }}
in practice we are using the CreateNew Attribute.

In the CustomerQueueController.cs we get a reference to a service by usind the ServiceDependency attribute.
I ask why?
May we use the serviceDependency attribute insted of CreateNew in the CustomerQueueService property?
If not, why?
Which are the differences between this two attributes? they initializes automatically, at run time, an object and provides a reference to it using IoC technique.
Maybe CreateNew is only for Controller and ServiceDependency is only for services?

Thanks. Antonio P.
Jan 8, 2006 at 7:12 PM
originally posted by: jburtch

For a good discussion of the differences in the two attributes look at the earlier thread entitled "ServiceDependency, CreateNew, InjectionConstructor "
here watch for wrapping

From the HOL, you'll notice that the ServiceDependency will continue to give you the same object but CreateNew will give you a new object. There is also a Dependency Attribute that looks like it can perform named object injection.

Justin Burtch