Application Settings. Values Slices

Application Settings supports an ordered multi-layered structure of values, it is provided by the Value Slices mechanism. Value Slices (or just Slices) sets the correspondence between the Setting Units and the objects of an arbitrary business class (persistent type), this type is called Slice Basis Type. At runtime, for each instance of this type a separate Slice Object will be created.

To get extensive knowledge about the Value Slices, refer to the Managing|Preferences|Administrator Settings section in the Xafari Northwind demo.

There are three Value Slices in application:

  • Default Slice
  • Department Slice
  • User Slice.


User Slice is the last (bottom), it provides a correspondence between the Setting values and app users (i.e. instances of the Xafari.Northwind.Security.InheritedUser type). There are a personal set of Setting Units for each user in the User Slice. Immediately it should be noted that a user with administrator permissions has access to all values in all Value Slices.


The business purpose of the Application Settings in the Xafari Northwind is to use Setting Unit's value as a default value when creating corresponding business object. For instance, Classifier.Product.Category Setting specifies a default value for the Category field of the Product object. The application gets the value of the appropriate Setting Unit for the current user.

The screenshot below shows a default values when creating Product objects by the different users. These values are defined in Setting Units of appropriate users (see the preceding screenshot).


Department Slice is an intermediate. Objects of the Department Slice and objects of the User Slice are in a relationship of hierarchical subordination (parent-child), i.e. each object of the Department Slice has several childs in the User Slice. The logic for calculation child objects must be implemented during designing the structure of Slices (see Slices Design).


Default Slice (root slice) is required and must always be present, it provides a global values.

The administrator has access to all values in all Slices.The user only has access to their personal values.


The value specified for the object from higher Value Slice is the default value for a subordinate object from the next Slice. The default value is displayed without the highlight. It is possible to override the value of Setting Unit within the any Slice, of course, if this value is editable (see Structure Design). The overriden value is highlighted in yellow.


The most popular use case of Value Slices is to assign each user a personal set of Setting Units (see Slices Design. Typical Scenarios).

The structure of Value Slices is defined in code. There is always a root Slice in the structure, it includes a single set of Setting Units - global settings, its values can be editing only by admin. Every next Slice is determined on the basis of some persistent type - Slice Basis Type. Each Slice, except the root, requires to define a list of rules:

  • a logic for calculation a child objects from the subordinate Slice
  • a logic to obtain a parent object from the higher Slice
  • a logic for calculation a display name of the Slice Object.


If Slice Basis Type supports the IHierarchyNode interface, then the generated Slice Objects will automatically replicate the hierarchical structure of the objects of the original type.

As you can see, at runtime, for each instance of the Slice Basis Type a separate Slice Object will be generated. The Slice Objects form a hierarchical structure, the calculation rules of sub-objects are defined in code. All values from all Slices are stored in the database.

Depending on the situation, the system can use both the global Setting values and the values from the specific Slice corresponding to a specific object (see Access in Code). This approach allows, in particular, to handle the Application Settings at the levels of the branch, division, department, workplace, etc.

When receiving data, the system can use the notion of a Current Slice which is intended to identify the Slice Object from which the values of the Setting Units is available to the current user. Current Slice is calculated during the initialization of the Slices structure and in most cases corresponds to an account of the current user.