Saturday, May 19, 2007

Creating Custom Services

You can create a service by adding a class to a module or the shell and applying the Service attribute to the class definition.

To create a service

  1. Add a new interface to an appropriate module.
  2. Add members that the interface will define.
  3. Add a new class to the module or the shell.
  4. Inherit from the interface and add the required functionality to the members.
  5. Add the Service attribute to the class definition as shown in the following code.

    [Service(Type=typeof(IMyService))]
    public class MyService : IMyService
The Service attribute triggers the creation of the service when a module is loaded. Service registration occurs using the type specified in the Type property. You can also add services to a WorkItem programmatically

No comments: