Services Model Service

Services Model Service is a special Xafari Service maintaining the interactions between the Services Model and all Xafari Services.

The Services Model is a separate Application Model object intended to store the parameters of all Xafari Services.

Services Model Service supports two use cases:

  • Reading the current Model
  • Modifying the Model

Reading the current Model

The ServicesModelService class implements the Model property that provides the access to the current settings of all services. The code snippet below demonstrates how to initialize the Branches service using the Model property.

  • c#
  • VB

public IModelBranches Model
    return ServicesModelService.Instance.Model.Branches();
protected override void InitializeCore()
  this.Active[IsEnabledKey] = this.Model.Enabled;
  // ...

Public ReadOnly Property Model As IModelBranches
    Return ServicesModelService.Instance.Model.Branches()
  End Get
End Property
Protected Overrides Sub InitializeCore()
  Me.Active(IsEnabledKey) = Me.Model.Enabled
  ' ...
End Sub

The service with settings includes a property that returns the corresponding node of the Services Model. In the example above the Model property is defined for the Branches service and contains the IModelBranches node of the Services Model.

During the initialization of the Branches service, the system analyzes its settings and initializes all required properties.

Modifying the Model

Services Model Service is a context service that allows modifying the Services Model in transaction. The code snippet below shows how to modify the settings of the Branches service:

  • c#
  • VB

public void SomeMethod()
  using (var objectSpace = this.Application.CreateObjectSpace())
    var settings = objectSpace.Xafari().ServicesModel.Edit.Branches();
    settings.EnabledTypes = branchEnabledTypes;
    settings.ReadMode = readMode;
    settings.Enabled = branchSwitchOn;

Public Sub SomeMethod()
  Using objectSpace = Me.Application.CreateObjectSpace()
    Dim settings = objectSpace.Xafari().ServicesModel.Edit.Branches()
    settings.EnabledTypes = branchEnabledTypes
    settings.ReadMode = readMode
    settings.Enabled = branchSwitchOn
  End Using
End Sub

The modification of the Services Model is supported by the Edit property of the ServicesModelService.ServiceSpaceContext context class. This property returns the IModelXafariServicesModel node from the Services Model object.

The Branches() extension method returns the IModelBranches node that provides all-kinds settings to the Branches service. The CommitChanges() method saves the modified values.

After the settings customization, the Branches service will reset to apply changes.


The settings are modified and saved for all services as a whole.

Service settings modification is actively used in service configuration modules and in Xafari Application Support.

For more info, refer to the Xafari Service section.