Go to content

Bulletcode.NET

Services

In order to use the built-in desktop services, call the RegisterDesktopServices() extension method of IServiceCollection:

services.RegisterDesktopServices();

The ListViewModelFactory service makes it possible to populate a list of drop-down items from a collection, enumeration or a class with constants. It contains the following methods:

  • GetItems() — returns a list of ListItemViewModel objects by retrieving the keys and names from the collection. An optional empty item, with null key and the specified name, can be also added.
  • GetEnumItems() — returns a list of ListItemViewModel objects representing the values and display names of the values of an enumeration type. It is similar to the GetEnumSelectList() method of the IHtmlHelper service available in web applications. An optional empty item can also be added.
  • GetConstItems() — returns a list of ListItemViewModel objects representing the values of all constants defined in a class. It is similar to the GetSelectList() method of the IConstHelper service available in web applications (see MVC for more information). An optional empty item can also be added.
  • GetConstName() — returns the display name of a single constant defined in a class. It is similar to the GetName() method of the IConstHelper service available in web applications (see MVC for more information).

The EnumHelper service makes it possible to get the display name of a single enumeration value. The GetDisplayName() method is similar to the GetEnumName() extension method of IHtmlHelper in web applications (see MVC for more information).

The LocalSettingsService service makes it possible to store local application settings in a JSON file. It contains the following methods:

  • Load() — loads the settings from the specified file and deserializes them into the specified class.
  • Save() — serializes the settings into JSON and saves them to the specified file.

In development mode, the location of the setting files is relative to the application’s base directory. In production mode, this location is relative to the path created using the local application data directory for the current user and the application name.