Extending Services

A service class in the Znode ecosystem is usually the last managed tier which breaks a requested user operation into several small-sized business logic instructions, data handling, and database transactions. It resides in the “Znode.Engine.Services” namespace.

The service classes are usually constructor-injected into API controllers or in some cases Cache helper classes.

Creating a Service

Assuming that the Znode’s visual studio solution already has custom class library projects created with “Znode.Custom.Engine.Services” and “Znode.Custom.Engine.Api” namespaces, creating a new service class can be accomplished with the following steps:

  1. Create a new interface with an appropriate name suffixed with the word “service” in the newly created custom class library project.

  2. Create a new class with a similar name to the interface (just exclude the letter “I” in the beginning). This class should inherit the “BaseService.cs” as well as implement the newly created service interface.

  3. Make sure that all the new service interfaces and service classes reside within the “Znode.Custom.Engine.Services” namespace.

  4. In the service interface, define all the members which are to be exposed to other components of Znode.

  5. Implement all the exposed members in the child service class. The service class can also contain private members which are only to be used within the scope of this class itself.

  6. Once the service interface and service class are ready to be used, make sure to register them both into the dependency registry which can be found in the “DependencyRegistration.cs” class under “Znode.Custom.Engine.Api” namespace.

Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.