Service Attribute ?

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

How service attribute create an istance of a class in which his constructor contains paramenters?
Thanks
Jan 26, 2006 at 4:45 PM
originally posted by: BradWilsonMSFT

The dependency injection system will attempt to resolve any undecorated constructor parameters with service dependencies (as though they had been decorated with ServiceDependency), pullings services from the WorkItem into which the item being created.
Jan 27, 2006 at 4:30 AM
originally posted by: ovidius

If i have this:

service
public class AService
{
public void AService (string aString)
{
.....
}
}

and this
Public Class MyController:Controller
{
private AService myService;

ServiceDependency
Public AService MyService
{set{..... }}}

..Then i could not use ServiceDependency?
How to avoid this?
Thanks
Jan 27, 2006 at 4:14 PM
originally posted by: PProvost

No, you mis-understand what Brad said...

If AService has a constructor that takes a parameter, then that parameter needs to be available to the dependency injection system.

Let me re-write your code a bit to explain:

Service
public class AService
{
public AService( AServiceConfigProvider provider )
{
...
}
}

Service
public class AServiceConfigProvider
{
public AServiceConfigProvider()
{
...
}
}

Does that make sense?
Jan 28, 2006 at 7:21 AM
originally posted by: ovidius

Ok, Thanks.
Now it's OK.