using EdjCase.JsonRpc.Router.Abstractions; using EdjCase.JsonRpc.Router.MethodProviders; using Microsoft.Extensions.Options; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace EdjCase.JsonRpc.Router.RouteProviders { public class RpcSingleRouteProvider : IRpcRouteProvider { public IOptions Options { get; } public RpcPath BaseRequestPath { get; } public RpcSingleRouteProvider(IOptions options) { this.Options = options ?? throw new ArgumentNullException(nameof(options)); this.BaseRequestPath = this.Options.Value?.BaseRequestPath ?? RpcPath.Default; } /// /// Gets all the method providers for the specified path /// /// Path to the methods /// All method providers for the specified path public List GetMethodsByPath(RpcPath path) => this.Options.Value?.MethodProviders ?? new List(); } public class SingleRouteOptions { public List MethodProviders { get; set; } = new List(); public RpcPath BaseRequestPath { get; set; } = RpcPath.Default; public void AddClass() { this.MethodProviders.Add(new ControllerPublicMethodProvider(typeof(T))); } } }