Architecture

The OCPI.Net package is designed to be as flexible as possible, allowing you to implement OCPI modules in any way you see fit. The package uses Asp.Net Core Controllers for handling incoming OCPI requests and returning OCPI responses. The package also contains a number of services which are used to perform various tasks such as validating incoming requests, generating responses, and handling errors.

The package follows a modular design, allowing you to use only the functionality you need. The package also allows you to implement multiple versions of the same module, allowing you to support multiple OCPI versions at the same time.

How the package works under the hood

The package uses the default Asp.Net Core dependency injection container to inject services into your controllers. The package also uses the default Asp.Net Core routing system to route incoming requests to the appropriate controllers.

The package uses the OcpiEndpoint attribute to determine which controllers are used to handle incoming OCPI requests. The package will perform an automated scan of your controllers and generate a list of supported OCPI versions for each module. See more in Implementation.

The package uses Exceptions as a way to handle errors. The exceptions can be thrown from anywhere in your code, and the package will automatically handle them and generate the appropriate OCPI response. Exception handling is done by the OcpiExceptionFilter attribute, which is automatically applied to all controllers that inherit from the OcpiController base class. Exceptions can be populated with a custom data payload, which will be included in the OCPI response. See more in Error Handling.

Integration with Asp.Net Core

The OCPI.Net package is designed to be used with Asp.Net Core. The package contains a OcpiController base class which you can use to implement your own OCPI controllers. This class contains a number of methods which you can use to handle incoming OCPI requests and generate OCPI responses.