/// <param name="type">Class type that the method is in</param> /// <param name="route">Request route the method can be called from</param> /// <param name="methodInfo">Reflection information about the method</param> /// <param name="serviceProvider">(Optional) Service provider to be used as an IoC Container</param> /// <param name="jsonSerializerSettings">Json serialization settings that will be used in serialization and deserialization for rpc requests</param> public RpcMethod(Type type, RpcRoute route, MethodInfo methodInfo, IServiceProvider serviceProvider = null, JsonSerializerSettings jsonSerializerSettings = null) { this.type = type; this.Route = route; this.methodInfo = methodInfo; this.parameterInfoList = methodInfo.GetParameters(); this.serviceProvider = serviceProvider; this.jsonSerializerSettings = jsonSerializerSettings; }
/// <param name="type">Class type that the method is in</param> /// <param name="route">Request route the method can be called from</param> /// <param name="methodInfo">Reflection information about the method</param> /// <param name="serviceProvider">(Optional) Service provider to be used as an IoC Container</param> /// <param name="jsonSerializerSettings">Json serialization settings that will be used in serialization and deserialization for rpc requests</param> public RpcMethod(Type type, RpcRoute route, MethodInfo methodInfo, IServiceProvider serviceProvider = null, JsonSerializerSettings jsonSerializerSettings = null) { this.type = type; this.Route = route; this.methodInfo = methodInfo; this.parameterInfoList = methodInfo.GetParameters(); this.serviceProvider = serviceProvider; this.jsonSerializerSettings = jsonSerializerSettings; IEnumerable <Attribute> customAttributes = type.GetTypeInfo().GetCustomAttributes(); this.AuthorizeDataList = customAttributes.OfType <IAuthorizeData>().ToList(); this.AllowAnonymous = customAttributes.OfType <IAllowAnonymous>().Any(); }
/// <summary> /// Registers the class's public methods to be used in the Rpc api under the optional route name /// </summary> /// <typeparam name="T">Class to open up to the Rpc api</typeparam> /// <param name="routeName">Optional route to put the class's Rpc methods</param> public void RegisterClassToRpcRoute <T>(string routeName = null) { Type type = typeof(T); RpcRoute route = this.Routes.GetByName(routeName); if (route == null) { route = new RpcRoute(routeName); this.Routes.Add(route); } bool uniqueClass = route.AddClass <T>(); if (uniqueClass) { return; } string alreadyRegisteredMessage = $"Type '{type.FullName}' has already been registered " + $"with the Rpc router under the route '{routeName}'"; throw new ArgumentException(alreadyRegisteredMessage); }