Services Model Wrappers. Learn More

Services Model Wrappers classes property validation

The Required properties of the Services Model Wrappers classes are validated automatically. See the sample of defining a node of the Services Model below.

  • c#
  • VB

public interface IModelServicesNumeratorLink : IModelNode
  string DisplayName { get; }
  IModelClass ModelClass { get; set; }

Public Interface IModelServicesNumeratorLink
  Inherits IModelNode
  <Browsable(False)> _
ReadOnly Property DisplayName As String
  <Required> _
<DataSourceProperty("Application.BOModel")> _
Property ModelClass As IModelClass
End Interface

To the IModelServicesNumeratorLink.ModelClass property, the RequiredAttribute is applied. When implementing a Services Model Wrapper (in this case, it is the NumeratorLinkCfgObject class), there is no need to use the RuleRequiredFieldAttribute for the property of the NumeratorLinkCfgObject.ModelClass. The validation rule for this field will be generated automatically based on the metadata of the Model node corresponding to the wrapper (i.e. IModelServicesNumeratorLink).

The automatic generation of the validation rules is performed by the Xafari.BC.Xas.Services.ServiceCfgObjectValidationRulesGenerator class of the Xafari Framework.

ReadOnly properties

If some property of a Services Model node should not be edited (e.g. when the ModelReadOnlyAttribute, ReadOnlyAttribute is applied to the property), then this limitation should be assigned to the required property of the wrapper class in the Detail View of the corresponding Services Model Wrapper object.

For such fields, the prohibition to edit is set by the Xafari.BC.Xas.Services.ServiceCfgObjectDetailLogicController.

How to get Services Model Wrapper instances.

If the Services Model contains the corresponding node, then the instance of the Service Model Wrapper can be get through the ObjectSpace.GetObjectByKey<>() method. The key for the method is the path to an existing node of the Services Model:

  • c#
  • VB

var objectSpace = Application.CreateObjectSpace(typeof(NumeratorsCfgObject));
var numeratorsCfgObject = objectSpace.GetObjectByKey<NumeratorsCfgObject>("Xafari\\Services\\Numerators");

Private objectSpace As var = Application.CreateObjectSpace(GetType(NumeratorsCfgObject))
Private numeratorsCfgObject As var = objectSpace.GetObjectByKey(Of NumeratorsCfgObject)("Xafari\Services\Numerators")


When creating an ObjectSpace via calling the Application.CreateObjectSpace method, the type of the object should be passed to the method. It is used to create a NonPersistentObjectSpace required for the stable functioning of the Services Model Wrappers.