Introduction
IService is the interface for the consumer side of the service stack. Service implementation processes requests by passing them through handlers which participate in building the result object.
// Create service
IService service = Services.Create(ServiceHandlers.Instance);
// Query for a type
Type type = service.GetRequired<TypeRequest, Type>("System.String");
Service implementations are accessible from various interfaces:
IServiceProvider └── IServiceBase ├── IService │ └── IServiceDisposable ├── IServiceT │ └── IServiceOf<Response> │ └── IService<Request, Response> │ └── IServiceDisposable<Request, Response> │ ├── IServiceCancellable ├── IServiceDecoration │ └── IServiceCast ├── IServiceObservable └── IServiceCastable ─── IServiceContainer ─── IServiceDecorator
Full Example
Full example
using System;
using Avalanche.Service;
using static System.Console;
public class service_index
{
public static void Run()
{
{
// <01>
// Create service
IService service = Services.Create(ServiceHandlers.Instance);
// Query for a type
Type type = service.GetRequired<TypeRequest, Type>("System.String");
// </01>
// Print service
Console.WriteLine(service.ToString());
}
}
}