using EdjCase.JsonRpc.Router.Abstractions; 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 RpcManualRouteProvider : IRpcRouteProvider { private IOptions Options { get; } public RpcManualRouteProvider(IOptions options) { this.Options = options ?? throw new ArgumentNullException(nameof(options)); } public RpcPath BaseRequestPath => this.Options.Value.BaseRequestPath; /// /// Gets all the routes from all the cofiguration /// /// All the available routes public HashSet GetRoutes() { if(this.Options.Value.Routes?.Keys != null) { return new HashSet(this.Options.Value.Routes.Keys); } return new HashSet(); } /// /// 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) { if(this.Options.Value.Routes == null || !this.Options.Value.Routes.TryGetValue(path, out List methods)) { return new List(); } return methods; } } }