Use Service into a service

Topics: CAB & Smart Client Software Factory
Dec 19, 2007 at 11:32 PM
can i use a service into another service ?
For example can i use a SecurityService into a UIMenuService to add or not a Item in a menu ?

Dec 21, 2007 at 2:06 PM

You can add the ServiceDependency attribute to a property in your service to declaratively obtain a reference to another service:

private IAccountServices  _accountServices;
public IAccountServices AccountServices
   set { _accountServices = value; }

Also, you can use the ServiceDependency attribute for the arguments in your service constructor. This means that ObjectBuilder will instantiate the required services when it creates the dependent object.

private IAccountServices  _accountServices;
public MyService([ServiceDependency] IAccountServices accountServices)
   _accountServices = accountServices;


Sebastian Iacomuzzi