Click or drag to resize

CObjectImplBase Class

Base class for Business Objects implementations.
Inheritance Hierarchy
SystemObject
  SystemMarshalByRefObject
    PDTec.IceNet.Sdk.ImplementationCObjectImplBase
      More...

Namespace:  PDTec.IceNet.Sdk.Implementation
Assembly:  PDTec.IceNet.Sdk (in PDTec.IceNet.Sdk.dll) Version: 7.2.0.0 (7.2.7583.15464)
Syntax
C#
public abstract class CObjectImplBase : MarshalByRefObject, 
	IObjectImpl, IObject

The CObjectImplBase type exposes the following members.

Constructors
  NameDescription
Public methodCObjectImplBase
Initializes a new instance of the CObjectImplBase class
Top
Properties
Methods
  NameDescription
Public methodAddKey
Public methodAsT
Public methodAsBaseT
Public methodCastT
Public methodCastBaseT
Public methodChangeObjType
Public methodCopyTo
Public methodCreateObjRef
Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
(Inherited from MarshalByRefObject.)
Public methodDeleteKey
Public methodDestroy
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetAttrValue(IAttrDef)
Public methodGetAttrValue(String, String)
Public methodGetAttrValue(IAttrDef, Boolean)
Public methodGetAttrValue(String, String, Boolean)
Public methodGetAttrValues
Public methodGetFolder
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetKeys
Public methodGetLifetimeService
Retrieves the current lifetime service object that controls the lifetime policy for this instance.
(Inherited from MarshalByRefObject.)
Public methodGetLockInfo
Public methodGetObjType
Public methodGetRelationships(RelDirection)
Public methodGetRelationships(String, RelDirection)
Public methodGetRelationships(IRelType, RelDirection)
Public methodGetSingleRelationship(String, RelDirection)
Public methodGetSingleRelationship(IRelType, RelDirection)
Public methodGetTableAttrTemplateRow
Public methodGetTableAttrValues
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodInitializeLifetimeService
Obtains a lifetime service object to control the lifetime policy for this instance.
(Inherited from MarshalByRefObject.)
Public methodIsOf(String)
Public methodIsOf(IObjType)
Public methodLock
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Protected methodMemberwiseClone(Boolean)
Creates a shallow copy of the current MarshalByRefObject object.
(Inherited from MarshalByRefObject.)
Public methodMoveTo
Public methodQueryInterface
Public methodReload
Public methodSetAttrValue(IAttrDef, Object)
Public methodSetAttrValue(String, String, Object)
Public methodSetAttrValues
Public methodSetRelationshipIndex
Public methodSetRelationshipIndices
Public methodSetTableAttrValues
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Public methodTouch
Public methodTriggerEventEventImpl, EventArgs
Public methodTryCastT
Public methodTryCastBaseT
Public methodTryGetAttrValue(IAttrDef, Boolean)
Public methodTryGetAttrValue(IAttrDef, DateTime)
Public methodTryGetAttrValue(IAttrDef, Double)
Public methodTryGetAttrValue(IAttrDef, Int64)
Public methodTryGetAttrValue(IAttrDef, Object)
Public methodTryGetAttrValue(IAttrDef, String)
Public methodTryGetAttrValue(String, String, Boolean)
Public methodTryGetAttrValue(String, String, DateTime)
Public methodTryGetAttrValue(String, String, Double)
Public methodTryGetAttrValue(String, String, Int64)
Public methodTryGetAttrValue(String, String, Object)
Public methodTryGetAttrValue(String, String, String)
Public methodTryGetSingleRelationship(String, RelDirection, IRelationship)
Public methodTryGetSingleRelationship(IRelType, RelDirection, IRelationship)
Public methodUnLock
Top
Extension Methods
  NameDescription
Public Extension MethodGetFolderId
Gets the folder ID without unneccessarily retrieving the full folder information.
(Defined by ModelExtensions.)
Public Extension MethodGetRepository
Gets the corresponding repository for an object.
(Defined by ModelExtensions.)
Public Extension MethodIsConnected(String, RelDirection)Overloaded.
Detects whether an object is connected by at least one relationship of a specific type.
(Defined by ModelExtensions.)
Public Extension MethodIsConnected(IRelType, RelDirection)Overloaded.
Detects whether an object is connected by at least one relationship of a specific type.
(Defined by ModelExtensions.)
Top
Examples

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 BO interface definition.
  • The BO implementation.
  • The BO factory class with the declaration of associated ice.NET object types.
  • The registration of BO assemblies.
  • A usage example.

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:

C#
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:

C#
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:

C#
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
<?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:

C#
IVehicle pVehicle = Repository.Get<IVehicle>(Request["vid"]);

double price = pVehicle.CalculatePrice(DateTime.UtcNow, DateTime.UtcNow.AddDays(2.0));
See Also
Inheritance Hierarchy
SystemObject
  SystemMarshalByRefObject
    PDTec.IceNet.Sdk.ImplementationCObjectImplBase
      PDTec.IceNet.Domain.AuditTrail.BusinessObjects.ImplementationCAuditTrailImplBase
      PDTec.IceNet.Domain.AuditTrail.BusinessObjects.ImplementationCTraceableImplBase
      PDTec.IceNet.Domain.Development.BusinessObjects.ImplementationCChart2Impl
      PDTec.IceNet.Domain.Development.BusinessObjects.ImplementationCChartImplBase
      PDTec.IceNet.Domain.Development.BusinessObjects.ImplementationCDataChartImplBase
      PDTec.IceNet.Domain.Development.BusinessObjects.ImplementationCDocumentationImplBase
      PDTec.IceNet.Domain.Development.BusinessObjects.ImplementationCModelChart2Impl
      PDTec.IceNet.Domain.Development.BusinessObjects.ImplementationCModelChartImplBase
      PDTec.IceNet.Domain.Development.BusinessObjects.ImplementationCModelingPackageImplBase
      PDTec.IceNet.Domain.Development.BusinessObjects.ImplementationCOrganizationChartImplBase
      PDTec.IceNet.Domain.Development.BusinessObjects.ImplementationCPackageChartImplBase
      PDTec.IceNet.Domain.Folders.BusinessObjects.ImplementationCFolderInfoImplBase
      PDTec.IceNet.Domain.Lifecycle.BusinessObjects.ImplementationCInitialStateImplBase
      PDTec.IceNet.Domain.Lifecycle.BusinessObjects.ImplementationCLifecycleableImplBase
      PDTec.IceNet.Domain.Lifecycle.BusinessObjects.ImplementationCLifecycleActionImplBase
      PDTec.IceNet.Domain.Lifecycle.BusinessObjects.ImplementationCLifecycleImplBase
      PDTec.IceNet.Domain.Lifecycle.BusinessObjects.ImplementationCLifecycleProgramActionImplBase
      PDTec.IceNet.Domain.Lifecycle.BusinessObjects.ImplementationCLifecycleScriptActionImplBase
      PDTec.IceNet.Domain.Lifecycle.BusinessObjects.ImplementationCStandardStateImplBase
      PDTec.IceNet.Domain.Lifecycle.BusinessObjects.ImplementationCStateImplBase
      PDTec.IceNet.Domain.Lifecycle.BusinessObjects.ImplementationCTerminalStateImplBase
      PDTec.IceNet.Domain.Lifecycle.BusinessObjects.ImplementationCTransitionImplBase
      PDTec.IceNet.Domain.Lifecycle.BusinessObjects.ImplementationCTransitionProgramRequirementImplBase
      PDTec.IceNet.Domain.Lifecycle.BusinessObjects.ImplementationCTransitionRequirementImplBase
      PDTec.IceNet.Domain.Subscription.BusinessObjects.ImplementationCMessagesImplBase
      PDTec.IceNet.Domain.Subscription.BusinessObjects.ImplementationCSubscribableImplBase
      PDTec.IceNet.Domain.Subscription.BusinessObjects.ImplementationCSubscriberImplBase
      PDTec.IceNet.Domain.Subscription.BusinessObjects.ImplementationCSubscriptionConfigImplBase
      PDTec.IceNet.Domain.UnitOfMeasurement.BusinessObjects.ImplementationCObjAttrUnitImplBase
      PDTec.IceNet.Domain.UnitOfMeasurement.BusinessObjects.ImplementationCObjTypeUnitsImplBase
      PDTec.IceNet.Domain.UnitOfMeasurement.BusinessObjects.ImplementationCRelAttrUnitImplBase
      PDTec.IceNet.Domain.UnitOfMeasurement.BusinessObjects.ImplementationCRelTypeUnitsImplBase
      PDTec.IceNet.Domain.UnitOfMeasurement.BusinessObjects.ImplementationCUnitImplBase
      PDTec.IceNet.Domain.UserManagement.BusinessObjects.ImplementationCPartyImplBase
      PDTec.IceNet.Domain.UserManagement.BusinessObjects.ImplementationCTeamImplBase
      PDTec.IceNet.Domain.UserManagement.BusinessObjects.ImplementationCUserImplBase