Introduction
A handler is an object on the producer side of a service stack. It participates in a query. It can initialize, decorate, and finalize results. Handler gets an IQuery<Request, Response> argument, which carries request and result objects, context dictionary, and service stack for futher queries.
There are five main handler interfaces. Any of which can be used for implementation.
IHandlerBase ├── IHandler<Request, Response> ├── IHandlerAsync<Request, Response> ├── IHandler └── IHandlerAsync
Handler implements one of the four IHandler interfaces.
[Export<IHandlerBase>, Order(1000)]
public class TypeHandler : IHandler<string, Type>
{
public void Handle(IQuery<string, Type> query)
{
// Already handled
if (query.Handled()) return;
// Find type
Type? type = Type.GetType(query.Request);
// No type found
if (type == null) return;
// Assign result
query.Response.SetValue(type);
}
}
All handler interfaces.
IHandlerBase ├── IHandlerBaseSync │ ├── IHandler │ │ └── IHandlerWithOrder │ └── IHandlerT │ └── IHandler<Request, Response> │ └── IHandlerWithOrder<Request, Response> │ ├── IHandlerBaseAsync │ ├── IHandlerAsync │ │ └── IHandlerAsyncWithOrder │ └── IHandlerAsyncT │ └── IHandlerAsync<Request, Response> │ └── IHandlerAsyncWithOrder<Request, Response> │ ├── IHandlerDecoration │ └── IHandlerCast └── IHandlerCastable