References to services are obtainable either programmatically or declaratively.
I. To obtain a reference to a service programmatically
- Call the Get method of the Services collection of the WorkItem, passing in the type of service as shown in the following code.
II. To obtain a reference to a service declarativelyIMyService myServ = (IMyService)myWorkItem.Services.Get(typeof(IMyService));
// or using generics
IMyService myServ = myWorkItem.Services.Get();
- Add the ServiceDependency attribute to a property in your class that that is of the type of service or interface you require, as shown in the following code.
private IMyService service;
[ServiceDependency]
public IMyService MyService
{
set { service = value; }
}
No comments:
Post a Comment