IObjectImpl Interface |
Namespace: PDTec.IceNet.Core.Model.Implementation
public interface IObjectImpl : IObject
The IObjectImpl type exposes the following members.
Name | Description | |
---|---|---|
ChangedBy |
Gets the name of the user who changed the object last.
(Inherited from IObject.) | |
ChangedOn |
Gets the point of time the object was changed last.
(Inherited from IObject.) | |
CreatedBy |
Gets the name of the user who created the object.
(Inherited from IObject.) | |
CreatedOn |
Gets the point of time the object was created.
(Inherited from IObject.) | |
Description |
Gets or sets the object description. The description can be empty.
(Inherited from IObject.) | |
Folder |
Gets the containing folder.
(Inherited from IObject.) | |
Id |
Gets the object ID. The ID is generated by the platform and
cannot be modified.
(Inherited from IObject.) | |
IsLocked |
Indicates if the object is locked.
(Inherited from IObject.) | |
IsValid |
Indicates if the object instance is valid. The object becomes
invalid if the Destroy method has been called.
(Inherited from IObject.) | |
LockedBy |
Gets the name of the user who holds a lock on the object, empty
string if the object is not locked.
(Inherited from IObject.) | |
LockedOn |
Gets the lock timestamp, if object is locked. DateTime.MinValue if not.
(Inherited from IObject.) | |
Name |
Gets or sets the object name. The name cannot be an empty string. It is
modifiable and does not have to be unique.
(Inherited from IObject.) | |
ObjType |
Gets the object type.
(Inherited from IObject.) | |
Repository |
Provides access to the Business Objects Repository.
|
Name | Description | |
---|---|---|
AddKey |
Adds a new key to the object. The key must be unique
within the system context (e.g. unique per database).
(Inherited from IObject.) | |
AsT | Obsolete.
Casts to a Business Object interface.
(Inherited from IObject.) | |
AsBaseT | Obsolete.
Provides access to BO implementation of supertypes.
| |
CastT |
Casts to a Business Object interface. Throws an exception if the Business Object
interface is not available for this object.
(Inherited from IObject.) | |
CastBaseT |
Provides access to BO implementation of supertypes.
| |
ChangeObjType |
Change the object type.
(Inherited from IObject.) | |
CopyTo |
Copies the object. Attributes of the object are copied, relationships not.
(Inherited from IObject.) | |
DeleteKey |
Removes a key from the object.
(Inherited from IObject.) | |
Destroy |
Deletes the object (and its relationships).
(Inherited from IObject.) | |
GetAttrValue(IAttrDef) |
Retrieves the specified attribute value.
(Inherited from IObject.) | |
GetAttrValue(String, String) |
Retrieves the specified attribute value.
(Inherited from IObject.) | |
GetAttrValue(IAttrDef, Boolean) | Obsolete.
Retrieves the specified attribute value and indicates if the value is assigned.
(Inherited from IObject.) | |
GetAttrValue(String, String, Boolean) | Obsolete.
Retrieves the specified attribute value and indicates if the value is assigned.
(Inherited from IObject.) | |
GetAttrValues |
Get all attribute values of the object.
(Inherited from IObject.) | |
GetFolder |
Retrieves the object's folder.
(Inherited from IObject.) | |
GetKeys |
Retrieves the object's (unique) keys.
(Inherited from IObject.) | |
GetLockInfo |
Retrieves information about the object's lock status.
(Inherited from IObject.) | |
GetObjType |
Retrieve the object type.
(Inherited from IObject.) | |
GetRelationships(RelDirection) |
Retrieves all attached relationships of a specific direction (regardless of their relationship type).
(Inherited from IObject.) | |
GetRelationships(String, RelDirection) |
Retrieves all attached relationships of a specific role (relationship type/direction combination).
(Inherited from IObject.) | |
GetRelationships(IRelType, RelDirection) |
Retrieves all attached relationships of a specific relationship type in a
specific direction.
(Inherited from IObject.) | |
GetSingleRelationship(String, RelDirection) |
Retrieves a single relationship (omit the array overhead).
(Inherited from IObject.) | |
GetSingleRelationship(IRelType, RelDirection) |
Retrieves a single relationship (omit the array overhead).
(Inherited from IObject.) | |
GetTableAttrTemplateRow |
Gets a table attribute template row.
(Inherited from IObject.) | |
GetTableAttrValues |
Gets the table attribute values.
(Inherited from IObject.) | |
IsOf(String) |
Indicates if the object conforms to a specific object type directly
or indirectly (is a subtype of).
(Inherited from IObject.) | |
IsOf(IObjType) |
Indicates if the object conforms to a specific object type directly
or indirectly (is a subtype of).
(Inherited from IObject.) | |
Lock |
Lock the object.
(Inherited from IObject.) | |
MoveTo |
Moves the object to another folder.
(Inherited from IObject.) | |
QueryInterface |
Cast to a Business Object interface.
(Inherited from IObject.) | |
Reload |
Refreshes the object data from secondary storage (e.g. database)
if available. Use this method to retrieve up-to-date audit information
(ChangedBy, ChangedOn properties).
(Inherited from IObject.) | |
SetAttrValue(IAttrDef, Object) |
Stores the specified attribute value.
(Inherited from IObject.) | |
SetAttrValue(String, String, Object) |
Stores the specified attribute value.
(Inherited from IObject.) | |
SetAttrValues |
Set multiple attribute values with a single method call.
(Inherited from IObject.) | |
SetRelationshipIndex |
Re-position a relationship within the object/reltype/direction order.
(Inherited from IObject.) | |
SetRelationshipIndices |
Re-order all relationships of a object/reltype/direction context.
(Inherited from IObject.) | |
SetTableAttrValues |
Sets the table attribute values.
(Inherited from IObject.) | |
Touch |
Updates the ChangedBy and ChangedOn information.
(Inherited from IObject.) | |
TriggerEventEventImpl, EventArgs |
Triggers a BO event.
| |
TryCastT |
Casts to a Business Object interface.
(Inherited from IObject.) | |
TryCastBaseT |
Provides access to BO implementation of supertypes.
| |
TryGetAttrValue(IAttrDef, Boolean) |
Attempts to get the specified attribute value and indicates if the value is assigned.
(Inherited from IObject.) | |
TryGetAttrValue(IAttrDef, DateTime) |
Attempts to get the specified attribute value and indicates if the value is assigned.
(Inherited from IObject.) | |
TryGetAttrValue(IAttrDef, Double) |
Attempts to get the specified attribute value and indicates if the value is assigned.
(Inherited from IObject.) | |
TryGetAttrValue(IAttrDef, Int64) |
Attempts to get the specified attribute value and indicates if the value is assigned.
(Inherited from IObject.) | |
TryGetAttrValue(IAttrDef, Object) |
Attempts to get the specified attribute value and indicates if the value is assigned.
(Inherited from IObject.) | |
TryGetAttrValue(IAttrDef, String) |
Attempts to get the specified attribute value and indicates if the value is assigned.
(Inherited from IObject.) | |
TryGetAttrValue(String, String, Boolean) |
Attempts to get the specified attribute value and indicates if the value is assigned.
(Inherited from IObject.) | |
TryGetAttrValue(String, String, DateTime) |
Attempts to get the specified attribute value and indicates if the value is assigned.
(Inherited from IObject.) | |
TryGetAttrValue(String, String, Double) |
Attempts to get the specified attribute value and indicates if the value is assigned.
(Inherited from IObject.) | |
TryGetAttrValue(String, String, Int64) |
Attempts to get the specified attribute value and indicates if the value is assigned.
(Inherited from IObject.) | |
TryGetAttrValue(String, String, Object) |
Attempts to get the specified attribute value and indicates if the value is assigned.
(Inherited from IObject.) | |
TryGetAttrValue(String, String, String) |
Attempts to get the specified attribute value and indicates if the value is assigned.
(Inherited from IObject.) | |
TryGetSingleRelationship(String, RelDirection, IRelationship) |
Tries to retrieves a single relationship.
(Inherited from IObject.) | |
TryGetSingleRelationship(IRelType, RelDirection, IRelationship) |
Tries to retrieves a single relationship.
(Inherited from IObject.) | |
UnLock |
Unlock the object.
(Inherited from IObject.) |
Name | Description | |
---|---|---|
GetFolderId |
Gets the folder ID without unneccessarily retrieving the full folder information.
(Defined by ModelExtensions.) | |
GetRepository |
Gets the corresponding repository for an object.
(Defined by ModelExtensions.) | |
IsConnected(String, RelDirection) | Overloaded.
Detects whether an object is connected by at least one relationship of a specific type.
(Defined by ModelExtensions.) | |
IsConnected(IRelType, RelDirection) | Overloaded.
Detects whether an object is connected by at least one relationship of a specific type.
(Defined by ModelExtensions.) |
This example explains how to implement ice.NET Business Objects (BOs). The data model that is used for this example is part of the ice.NET Ice Car Rental turorial and can be found in the PDTec.ICR model package.
The example consists of multiple parts:
The first part of the example shows a BO interface definition. It is a normal C# interface that derives from the IObject interface. It can contain arbitrary methods and properties .
The following code is stored in the file IVehicle.cs:
using System; using PDTec.IceNet.Core.Model; namespace PDTec.ICR.BusinessLogic.BusinessObjects { public interface IVehicle : IObject { double CurrentMileage { get; set; } double CalculatePrice(DateTime pFromDate, DateTime pToDate); } }
The interface IVehicle is implemented in the next code example. To implement a BO interface a class is required that is derived from PDTec.IceNet.Sdk.Implementation.CObjectImplBase" and implements the BO interface.
The following code is stored in the file CVehicleImpl.cs:
using System; using System.Collections; using PDTec.IceNet.Core.Model; using PDTec.IceNet.Core.Model.Implementation; using PDTec.IceNet.Sdk.Implementation; using PDTec.ICR.BusinessLogic.BusinessObjects; namespace PDTec.ICR.BusinessLogic.BusinessObjects.Implementation { public class CVehicleImpl : CObjectImplBase, IVehicle { public CVehicleImpl(IRepository pRepository, IObjectImpl pObject) : base(pRepository, pObject) { } public double CurrentMileage { get { return (double)GetAttrValue("PDTec.ICR.Vehicle", "CurrentMileage"); } set { SetAttrValue("PDTec.ICR.Vehicle", "CurrentMileage", value); } } private IModel Model { get { IRelationship pRelationship = GetSingleRelationship("PDTec.ICR.VehicleModel", RelDirection.Forward); IModel pResult = pRelationship.GetObject(Direction.To).Cast<IModel>(); return pResult; } } public double CalculatePrice(DateTime pFromDate, DateTime pToDate) { TimeSpan pTimeSpan = pToDate - pFromDate; double price = pTimeSpan.Days * DailyRate - Model.CalculateRebate(this); return price; } } }
To associate the BO implementation with a modeled object type a BO factory is required. This factory class is decorated with a code attributes of type ObjectImplAttribute and implements IObjectImplFactory.
The property ObjTypeName defines the association with the ice.NET object type. All object instances of this type (or its subtypes) provide the BO methods declated in the BO interface.
The following code is stored in the file CVehicleImplFactory.cs:
using PDTec.IceNet.Core.Model; using PDTec.IceNet.Core.Model.Implementation; namespace PDTec.ICR.BusinessLogic.BusinessObjects.Implementation { [ObjectImpl(ObjTypeName="PDTec.ICR.Vehicle", Interface=typeof(IVehicle))] public class CVehicleImplFactory : IObjectImplFactory { public IObject CreateObject(IRepository pRepository, IObjectImpl pBaseImpl) { return new CVehicleImpl(pRepository, pBaseImpl); } } }
The BO factory provides the connection between interface, implementation and data model. In order to be used in an application, the containing .NET assembly must be registered with the .NET platform. The easies way to do this is to add a <implementationAssembly> tag that contains the assembly name into the application's configuration file as shown in the follwing example.
If the BO interface, the implementation and the factory class are distributed over multiple assemblies, the assembly containing the factory class must be registered in the configuration file.
The following code is part of a .NET configuration file (e.g. web.config):
<?xml version="1.0"?> <configuration> <configSections> <section name="ice.net" type="PDTec.IceNet.Sdk.ConfigSectionHandler,PDTec.IceNet.Sdk"/> </configSections> <ice.net> <database service="SQLServer" connectionString="server=(local)\SQLEXPRESS;trusted_connection=yes;database=icr" encrypted="false"/> <businessObjects> <implementationAssembly assemblyName="PDTec.ICR.BusinessLogic"/> </businessObjects> <!-- ... --> </ice.net> <!-- ... --> </configuration>
The following code shows how to use the BO methods:
IVehicle pVehicle = Repository.Get<IVehicle>(Request["vid"]); double price = pVehicle.CalculatePrice(DateTime.UtcNow, DateTime.UtcNow.AddDays(2.0));
This example explains how to reimplement a BO interface for a subtype and make use of the base (supertype) implementation.
The example consists of multiple parts:
The first part of the example shows the BO interface definition. It is designed for calcuating the speed of objects. It can be connected with object types such as PDTec.ICR.Model that describes vehicle models and its subtypes.
The following code is stored in the file IObjectInMotion.cs:
using PDTec.IceNet.Core.Model; namespace PDTec.ICR.BusinessLogic.BusinessObjects { public interface IObjectInMotion : IObject { double CalculateSpeed(int numberOfPassengers); } }
The interface IObjectInMotion is implemented for the root type of the PDTec.ICR.Model hierarchy. The implementation class CModelInMotionImpl contains the BO factory as an inner class. This is not necessary but avoids having to maintain an extra source file for the factory class.
We assume that object types of PDTec.ICR.Model provide an BO interface IModel that will be used in the implementation of IObjectInMotion.
The following code is stored in the file CModelInMotionImpl.cs:
using PDTec.IceNet.Sdk.Implementation; using PDTec.IceNet.Core.Model; using PDTec.IceNet.Core.Model.Implementation; namespace PDTec.ICR.BusinessLogic.BusinessObjects.Implementation { public class CModelInMotionImpl : CObjectImplBase, IObjectInMotion { [ObjectImpl(ObjTypeName="PDTec.ICR.Model", Interface=typeof(IObjectInMotion))] public class CImplFactory : IObjectImplFactory { public IObject CreateObject(IRepository pRepository, IObjectImpl pBaseImpl) { return new CModelInMotionImpl(pRepository, pBaseImpl); } } //------------------ public CModelInMotionImpl(IRepository pRepository, IObjectImpl pObject) : base(pRepository, pObject) { } public double CalculateSpeed(int numberOfPassengers) { if (numberOfPassengers < 1) { throw new ArgumentException("numberOfPassengers"); } return Cast<IModel>().EnginePower / (double)numberOfPassengers; } } }
The interface IObjectInMotion is now reimplemented for the subtype PDTec.ICR.SportsCar. This type is modeled as a subtype of PDTec.ICR.Car which is a subtype of the hiearchy root type PDTec.ICR.Model.
The reimplementation makes use of the base implementation by calling the generic CastBaseT(IObjType) method.
The following code is stored in the file CSportsCarInMotionImpl.cs:
using PDTec.IceNet.Sdk.Implementation; using PDTec.IceNet.Core.Model; using PDTec.IceNet.Core.Model.Implementation; namespace PDTec.ICR.BusinessLogic.BusinessObjects.Implementation { public class CSportsCarInMotionImpl : CObjectImplBase, IObjectInMotion { [ObjectImpl(ObjTypeName="PDTec.ICR.SportsCar", Interface=typeof(IObjectInMotion))] public class CImplFactory : IObjectImplFactory { public IObject CreateObject(IRepository pRepository, IObjectImpl pBaseImpl) { return new CSportsCarInMotionImpl(pRepository, pBaseImpl); } } //------------------ public CSportsCarInMotionImpl(IRepository pRepository, IObjectImpl pObject) : base(pRepository, pObject) { } public double CalculateSpeed(int numberOfPassengers) { IObjType pBaseType = Repository.GetObjTypeByName(Constants.ObjType.Car); return 0.5 * (CastBase<IObjectInMotion>(pBaseType)).CalculateSpeed(numberOfPassengers)) + 0.5 * Cast<ISportsCar>().MaxSpeed; } } }