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 business object

A Scensum business object will usually have a set of properties that correspond to one or more tables in a database. In many cases there will also be a set of methods hosting some business logic.

Extending a Scensum business object is commonly done to change its behavior or to add properties or business logic. Adding properties that need to be persisted in the database will also involve extending the business object’s corresponding data mapper and repository.

Create interface

The new interface should extend the base interface.

C#
public class IExtendedProduct : Litium.Scensum.Product.Contract.BusinessObject.IProduct

Create class

The new business object should extend the base class and implement the new interface.

C#
public class ExtendedProduct : Litium.Scensum.Product.BusinessObject.Product, IExtendedProduct

Modify the IoC settings file

Instances of business objects are managed by the IoC container.

C#
IProduct product = IoC.Resolve<Litium.Scensum.Product.Contract.BusinessObject.IProduct>();

To get the IoC container to create an instance of your extended business object, the type definition in the IoC settings file needs to be modified.

XML
<component
id="Product"
lifestyle="transient"
service="Litium.Scensum.Product.Contract.BusinessObject.IProduct,
    Litium.Scensum.Product.Contract"
type="YourProject.ExtendedProduct, YourProject" />

Instances of business objects are usually retrieved from a service. A cast is needed to access members of the extended object.

C#
IExtendedProduct product = (IExtendedProduct)productService.GetById(productId);
MyTextBox.Text = product.MyNewProperty;