Custom Apply

One of the use cases is to design a Numerator in the Application Model and then to apply it in code. This topic describes this scenario.


The complete sample project is available in BusinessNumerators. You can view the code used in this lesson in the BusinessNumerators.Module|Controllers|NumerateByActionViewController.cs file.

Thus, we assume that Updater creates 15 objects as you can see in the code snippet below:

  • c#
  • VB

public class Updater : ModuleUpdater
  private void CreateNumerateByActionObject()
    if (this.ObjectSpace.GetObjects<NumerateByAction>().Any())
    for (var i = 1; i <= 15; i++)
      var obj = ObjectSpace.CreateObject<NumerateByAction>();
      obj.Name = "Object_" + i;

Public Class Updater
  Inherits ModuleUpdater
  Private Sub CreateNumerateByActionObject()
    If Me.ObjectSpace.GetObjects(Of NumerateByAction)().Any() Then
    End If
    Dim i = 1
    While i <= 15
      Dim obj = ObjectSpace.CreateObject(Of NumerateByAction)()
      obj.Name = "Object_" + i
      i += 1
    End While
  End Sub
End Class

These objects contain the Number property, the value of which is generated by the Action using the Numerators service.


First, design the Numerator via the Model Editor in Visual Studio. To do it, navigate to the Numerators node and set the AutoApply property's value to "False".


Then, go to the Xafari|Services|Numerators node, add a new item, and set its properties as shown in the picture below.


Link the Numerator to the required object as follows.


The Numerators service will process the required object when the Apply method is called. For instance, it may be done be the Action's ..._Execute event handler. The code snippet below demonstrates the numerateSelectedObjects_Execute event handler that is meant to enumerate all selected objects on the List View.

  • c#
  • VB

private void numerateSelectedObjects_Execute(object sender, SimpleActionExecuteEventArgs e)
  var selected = this.View.SelectedObjects;
  if (selected == null || selected.Count == 0)
  foreach (var obj in selected)

Private Sub numerateSelectedObjects_Execute(ByVal sender As Object, ByVal e As SimpleActionExecuteEventArgs)
  Dim selected = Me.View.SelectedObjects
  If selected Is Nothing OrElse selected.Count = 0 Then
  End If
  For Each obj In selected
End Sub

The images below show an objects collection before and after executing the Action: