Xafari Context Service. Initialization

The initialization of a context object is made by calling the Initialize() method right after the context object creation. During the process, the context object activation happens.

Note

There is no need to call the Initialize() method explicitly when implementing context services.

To initialize context object, it is required to override ServiceSpaceContextBase.InitializeCore() protected virtual method. Use this method to implement complex initialization operations, for instance, it may be an access to the Model Service. The code below demonstrates the InitializeCore() method of the Numerators service, in addition to the base functionality, it initialize the AutoApply property which gets default value from the service object.

  • c#
  • VB

protected override void InitializeCore()
{
  base.InitializeCore();
  this.AutoApply = this.Service.AutoApply;
}

Protected Overrides Sub InitializeCore()
  MyBase.InitializeCore()
  Me.AutoApply = Me.Service.AutoApply
End Sub

Note

The ServiceSpaceContextCreated service event is generated after the Initialize() method is called.