Creating Custom Services
Retired Content |
---|
This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. |
Typically, you will want to create custom services in your Composite UI Application Block applications to provide functionality for the views and controllers. You can create a service by adding a class to a module or the shell, and then applying the Service attribute to the class definition.
To create a service
Add a new interface to an appropriate module.
Add members that the interface will define.
Add a new class to the module or the shell.
Inherit from the interface and add the required functionality to the members.
Add the Service attribute to the class definition, as shown in the following code.
[Service(Type=typeof(IMyService))] public class MyService : IMyService
'Usage <Service(Type:=GetType(IMyService))> _ Public Class MyService Implements IMyService
The Service attribute triggers the creation of the service when a module is loaded. Service registration occurs by using the type specified in the Type property. You can also add services to a WorkItem programmatically, as explained in the section Adding Services earlier in this document. You can then use the functionality in the application by getting a reference to the service and calling its methods.