Våra sajter
Litium Studio Knowledgecenter

Knowledge Center för Litium Studio

Litium Scensum Knowledge Center

Knowledge Center för Litium Scensum

Litium Partner

Återfinns information som partner till Litium.

Support

Extending a service

The Scensum API is divided into two sets of services. There are public services and there are services that require authentication and authorization. The latter is called secure services. Both types of services can be customized according to your requirements.

The scope of a service is usually limited to one business object.

Calling a service method to get a business object (or a collection of business objects) will induce the following chain of events: the service calls a repository method, which in turn executes a stored procedure to get a result set where each row is processed by a data mapper, and the resulting business object (or collection of business objects) is returned.

To add your own mechanisms for caching, logging or event handling to a service, you can create a new service class that extends a built-in Scensum service and override one or more of the methods.

Create a class

Extend the appropriate service.

C#
public class ExtendedProductService : ProductService

Override method

C#
public override IProduct GetById(IChannel channel, int productId)
{
    // Add logging mechanism.
    new MyLoggerUtil().Log(“Getting product from database.”);

    return base.GetById(channel, productId);
}

Modify the IoC settings file

Service instances are managed by the IoC container. To get the IoC container to create an instance of your extended service, the type definition in the IoC settings file needs to be modified.

XML
<component
id="ProductService"
service="Litium.Scensum.Product.Contract.Service.IProductService, Litium.Scensum.Product.Contract"
type="YourProject.ExtendedProductService, YourProject" />