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.

Extending or Creating a Service

OOTB Znode has Znode.Api.Custom for extending the services in the SDK from the Full Source Code. Inside the \ZnodeMultifront\Projects\Libraries\Znode.Api.Custom project, the services and the IServices are extended. This same custom project can be utilized for creating a new service.

  1. To extend a service, under Znode.Api.Custom > Service > IService, create a new interface with an appropriate name suffixed with the word “service”. (For Example, We will create ICustomOrderService.cs)

  2. Next, under the Service > Service, create a new class with a similar name to the interface (just exclude the letter “I” in the beginning). This class should inherit the service you are trying to extend from the full source code, as well as implement the newly created service interface. (For example, we create a CustomOrderService which will inherit the OrderService that is present in the full source code).

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

  4. In the service interface, define all the members that 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.Api.Custom” > Helper.

For reference, OOTB Znode already has a service extended called "CustomPortalService.cs" which can be used as a reference to extend other services in OOTB Znode.

Did you find it helpful? Yes No

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