Zerto.WebApi.Rpc.ControllerBuilder 2.2.0.20

Prefix Reserved
dotnet add package Zerto.WebApi.Rpc.ControllerBuilder --version 2.2.0.20
                    
NuGet\Install-Package Zerto.WebApi.Rpc.ControllerBuilder -Version 2.2.0.20
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Zerto.WebApi.Rpc.ControllerBuilder" Version="2.2.0.20" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Zerto.WebApi.Rpc.ControllerBuilder" Version="2.2.0.20" />
                    
Directory.Packages.props
<PackageReference Include="Zerto.WebApi.Rpc.ControllerBuilder" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Zerto.WebApi.Rpc.ControllerBuilder --version 2.2.0.20
                    
#r "nuget: Zerto.WebApi.Rpc.ControllerBuilder, 2.2.0.20"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Zerto.WebApi.Rpc.ControllerBuilder@2.2.0.20
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Zerto.WebApi.Rpc.ControllerBuilder&version=2.2.0.20
                    
Install as a Cake Addin
#tool nuget:?package=Zerto.WebApi.Rpc.ControllerBuilder&version=2.2.0.20
                    
Install as a Cake Tool

Zerto.WebApi.ControllerBuilder:

About:

The purpose of this project is to allow .NET developers to create HTTP based services that are defined using interfaces.

.NET interfaces and data contracts are very convenient to work with when communicating between .NET applications, and both this project and Zerto.WebApi.ClientBuilder were created with the purpose of providing a simple way to publish and consume such services, without requiring the developer to be familiar with HTTP, JSON, ASP.NET and etc.

This project is a .NET Standard 2.0 project that builds upon the capabilities of Microsoft ASP.NET Core MVC Web API v2.2. This project contain both the controller generation logic and the web application that publish those controllers.

Glossary:

Controller - Class that handles incoming HTTP requests and send response back to the caller. Action - All the public methods of the controller are called action methods. Middleware - Allows adding extra logic into an ASP.NET web application pipeline to handle all requests and responses. Filter - Allows adding extra logic before or after a controller action. Action Filter - The last filter type in the ASP.NET pipeline, invoked immediately before and after the controller action. Action filters execute after the model binding stage (where the HTTP content has been serialized to .NET objects). Service Name - The name of the published service from the point of view of the service consumer. Each action is exposed as a URL, where the controller appears to be the parent directory of the action. We publish the controller (this "parent directory") using a service name that can be set during service registration.

Diagram:

╔════════╗   Request   ┌───────────┐   Request    ┌─────────────┐       ┌────────────────┐
║  HTTP  ║ ──────────> │ Action    │ ───────────> │             │ ────> │    Service     │
║ Client ║             │ Filter(s) │              │ Controller* │       │ Implementation │
║        ║ <────────── │           │ <─────────── │             │ <──── │  (Singleton)   │
╚════════╝   Response  └───────────┘   Response   └─────────────┘       └────────────────┘

* Auto-generated

External Components:

WebApiControllerBuilder - This is the main component of this project, this class use reflection to generate a controller for a given interface, each interface method becomes a controller action.

ControllerBuilderWebApplicationStartup - This class contains the startup logic of the web application that publishes the controllers. This class implements the IStartup interface in order to allow easier integration with web hosts.

Internal Components:

ControllerTypeRegistry - This class holds a reference to all the controllers that were generated, and is used to locate the controllers when starting the web application.

ServiceInstanceRegistry - We allow the developer to provide an instance of each service (that implements the interface) he wishes to expose, this class holds a reference to all the instances.

ActionFiltersRegistry - This class holds a reference to all the IActionFilter implementations provided by the caller.

Usage:

The developer should use WebApiControllerBuilder to register the services he wish to publish, and then start the web application by starting a web host that will execute the application Startup logic.

• The same service can be published multiple times using different service names. (Useful when you wish to expose two instances of the same service or the same instance using different action filters)

• It is possible to start multiple web applications, each publishes its own services (using a different port).

Limitations:

• It is currently not possible to associate additional controllers with a web application once it has started, removal of controllers from a running web application is also not currently possible.

• A service name must be unique within the scope of the process.

Interface definition rules:

Interface inheritence is supported, multiple input parameters are supported (both primitives and complex types), for complex types it is encouraged (but not mandatory) to use the DataContract class attribute.

Streaming: Only a single input stream and / or a single output stream is supported. (The same interface can contain both streaming and non-streaming methods)

An interface exposed via WebApiControllerBuilder must not contain any of the following:

  • Method overloading
  • Events
  • Method with ref parameter
  • Method with out parameter
  • Method with multiple input parameters that one of them is Stream.
  • Method declaring input / output parameter type that inherits from Stream (such parameter must be explicitly declared as Stream).

Note regarding Streams:

If your interface method returns a Stream, please note that Web API will call Stream.Close after the TCP connection using that stream is terminated. You should not close this Stream yourself or otherwise it may not be available to the client. If you wish to execute any post-close logic (e.g. deleting a temporary file), the best approach would be to implement a wrapper over the returned stream, override the Close method, and trigger any post-close logic there.

If your interface method accepts a Stream, there is no requirement to call Stream.Close.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.2.0.20 23,880 6/16/2021
2.2.0.19 598 6/15/2021