Litium API

In Litium 6 the a new API is introduced for the areas Customers and Media, in addition to Products, for which it was introduced in Litium 5. In future versions the new API will cover the rest of the product.

Structure

The API is structured into different assemblies to separate the domain entities and service contracts from the application logic. When you extend and build customer specific functionality, you only need to include references to the assemblies that contain domain entities and service contracts. This way there will be a minimal number of external dependencies.

A service contract can be either the domain service that will handle the entity or an extension point. Domain services have an abstract class as a contract and extension points have interfaces as a contract.

Domain entities and service contracts that have breaking changes, except classes or interfaces in the Internal namespace, will be announced in release notes for each release. Classes or interfaces in the Internal namespace should not be used in customer solutions and can be removed by Litium without prior notice.

Naming of the assemblies that contain the domain entities or service contracts:

  • Litium.Abstractions - contains core domain entities and service contracts.
  • Litium.Web.Abstractions - contains domain entities and service contracts for web applications.
  • Litium.Web.Mvc.Abstractions - contains domain entities and service contracts for ASP.NET MVC applications.
  • Litium.Web.WebApi.Abstractions - contains domain entities and service contracts for ASP.NET WebAPI applications.
  • Litium.Web.Administration.Abstractions – contains domain entities and service contracts for extending the administration interface.
  • Litium.Common - contains general functionality

The namespace in the assembly is the same as the assembly name without “Abstractions”.

Services

Applications can be designed through

  • static instance that contains the services and caches
  • dependency injection that holds the state of the services and inject the dependency (constructor parameters) for the service into the instance.

Services in API is designed to use dependency injection wherever possible. When using dependency injection, services can easily be extended or replaced. Services is used to create/read/update/delete the entity.

How to find the correct service

If the entity name is "Entity" the service name is "EntityService".

Example:

  • entity = BaseProduct
  • service = BaseProductService

The service exists in the same namespace as the entity.

Readonly entities

All entities that implement Litium.ComponentModel.IReadOnly can be in read-only mode to prohibit that the entity is changed. To change an entity that is read-only, you need to invoke the method MakeWritableClone to create a clone of the object that can be changed.

Database manipulation of data

Litium strongly advises against changing the data directly in the database. If you choose to do so anyway:

  • you are responsible to ensure business rules are met
  • you are responsible to ensure that correct events are fired
  • you are responsible to ensure that search indexes are updated.

API documentation

You can download complete reference to the current and previous versions of the Litium API here.

Is this page helpful?
Thank you for your feedback!