public static IServiceCollection AddJsonRpcHandler(this IServiceCollection services, params IJsonRpcHandler[] handlers) { foreach (var item in handlers) { services.AddSingleton(JsonRpcHandlerDescription.Infer(item)); } return(services); }
public sealed override T AddHandlers(params IJsonRpcHandler[] handlers) { foreach (var item in handlers) { Handlers.Add(JsonRpcHandlerDescription.Infer(item)); } return((T)(object)this); }
public static IServiceCollection AddJsonRpcHandler(this IServiceCollection services, string method, IJsonRpcHandler handler, JsonRpcHandlerOptions options = null) { services.AddSingleton(JsonRpcHandlerDescription.Named(method, handler, options)); return(services); }
public static IServiceCollection AddJsonRpcHandler(this IServiceCollection services, Type type, JsonRpcHandlerOptions options = null) { services.AddSingleton(JsonRpcHandlerDescription.Infer(type, options)); return(services); }
public static IServiceCollection AddJsonRpcHandler(this IServiceCollection services, JsonRpcHandlerFactory handlerFunc, JsonRpcHandlerOptions options = null) { services.AddSingleton(JsonRpcHandlerDescription.Named(null, handlerFunc, options)); return(services); }
internal static IContainer AddJsonRpcServerCore <T>(this IContainer container, JsonRpcServerOptionsBase <T> options) where T : IJsonRpcHandlerRegistry <T> { if (options.Output == null) { throw new ArgumentException("Output is missing!", nameof(options)); } if (options.Input == null) { throw new ArgumentException("Input is missing!", nameof(options)); } container = container.Populate(options.Services); container.RegisterInstance(options.Output, serviceKey: nameof(options.Output)); container.RegisterInstance(options.Input, serviceKey: nameof(options.Input)); container.RegisterInstance(options.MaximumRequestTimeout, serviceKey: nameof(options.MaximumRequestTimeout)); container.RegisterInstance(options.SupportsContentModified, serviceKey: nameof(options.SupportsContentModified)); container.RegisterInstance(options.Concurrency ?? -1, serviceKey: nameof(options.Concurrency)); container.RegisterInstance(options.InputScheduler, serviceKey: nameof(options.InputScheduler)); container.RegisterInstance(options.OutputScheduler, serviceKey: nameof(options.OutputScheduler)); if (options.CreateResponseException != null) { container.RegisterInstance(options.CreateResponseException); } container.RegisterMany <OutputHandler>( nonPublicServiceTypes: true, made: Parameters.Of .Type <PipeWriter>(serviceKey: nameof(options.Output)) .Type <IScheduler>(serviceKey: nameof(options.OutputScheduler)), reuse: Reuse.Singleton ); container.Register <RequestInvokerOptions>( made: Made.Of().Parameters .Type <TimeSpan>(serviceKey: nameof(options.MaximumRequestTimeout)) .Type <bool>(serviceKey: nameof(options.SupportsContentModified)) .Name("concurrency", serviceKey: nameof(options.Concurrency)), reuse: Reuse.Singleton); if (!container.IsRegistered <RequestInvoker>()) { container.Register <RequestInvoker, DefaultRequestInvoker>( made: Made.Of().Parameters .Type <IScheduler>(serviceKey: nameof(options.InputScheduler)), reuse: Reuse.Singleton); } container.Register <Connection>( made: Made.Of().Parameters .Type <PipeReader>(serviceKey: nameof(options.Input)) , reuse: Reuse.Singleton ); container.RegisterInstance(options.DefaultScheduler); container.RegisterMany <ResponseRouter>( serviceTypeCondition: type => type.IsInterface, reuse: Reuse.Singleton ); container.RegisterInstance(options.Handlers); container.RegisterInitializer <IJsonRpcHandlerCollection>( (collection, context) => { foreach (var description in context .ResolveMany <JsonRpcHandlerDescription>() .Concat( context .ResolveMany <IJsonRpcHandler>().Select(_ => JsonRpcHandlerDescription.Infer(_)) )) { collection.Add(description); } } ); container.RegisterMany <InstanceHasStarted>(nonPublicServiceTypes: true, reuse: Reuse.Singleton); return(container.AddJsonRpcMediatR()); }
public IJsonRpcHandlerCollection Add(JsonRpcHandlerDescription description) { _descriptions.Add(description); return(this); }
public sealed override T AddHandlerLink(string fromMethod, string toMethod) { Handlers.Add(JsonRpcHandlerDescription.Link(fromMethod, toMethod)); return((T)(object)this); }
public sealed override T AddHandler(string method, Type type, JsonRpcHandlerOptions?options = null) { Handlers.Add(JsonRpcHandlerDescription.Named(method, type, options)); return((T)(object)this); }
public sealed override T AddHandler(Type type, JsonRpcHandlerOptions?options = null) { Handlers.Add(JsonRpcHandlerDescription.Infer(type, options)); return((T)(object)this); }
public sealed override T AddHandler(JsonRpcHandlerFactory handlerFunc, JsonRpcHandlerOptions?options = null) { Handlers.Add(JsonRpcHandlerDescription.Infer(handlerFunc, options)); return((T)(object)this); }
public sealed override T AddHandlerLink(string sourceMethod, string destinationMethod) { Handlers.Add(JsonRpcHandlerDescription.Link(sourceMethod, destinationMethod)); return((T)(object)this); }
public sealed override T AddHandler(IJsonRpcHandler handler, JsonRpcHandlerOptions options = null) { Handlers.Add(JsonRpcHandlerDescription.Named(null, handler, options)); return((T)(object)this); }
public sealed override T AddHandler(string method, JsonRpcHandlerFactory handlerFunc, JsonRpcHandlerOptions options = null) { Handlers.Add(JsonRpcHandlerDescription.Named(method, handlerFunc, options)); return((T)(object)this); }