public static void GetGrpcMethods(string serviceName, Type serviceType, IGrpcMarshallerFactory marshallerFactory) { foreach (GrpcMethodHandlerInfo handler in GrpcReflection.EnumerateServiceMethods(serviceName, serviceType, marshallerFactory)) { Handers.AddOrUpdate(handler.GetHashString(), handler); InnerLogger.Log(LoggerLevel.Debug, handler.GetHashString()); } }
/// <summary> /// メソッド定義を生成します。 /// </summary> /// <typeparam name="TRequest">リクエストの型</typeparam> /// <typeparam name="TResponse">レスポンスの型</typeparam> /// <param name="serviceName">サービス名</param> /// <param name="handler">メソッドハンドラ情報</param> /// <param name="marshallerFactory">マーシャラーの生成処理</param> /// <returns>メソッド定義</returns> private static Method <TRequest, TResponse> CreateMethodCore <TRequest, TResponse>(string serviceName, GrpcMethodHandlerInfo handler, IGrpcMarshallerFactory marshallerFactory) { return(new Method <TRequest, TResponse>(handler.MethodType, serviceName, handler.Handler.Name, marshallerFactory.GetMarshaller <TRequest>(), marshallerFactory.GetMarshaller <TResponse>())); }
/// <summary> /// メソッド定義を生成します。 /// </summary> /// <param name="serviceName">サービス名</param> /// <param name="handler">メソッドハンドラ情報</param> /// <param name="marshallerFactory">マーシャラーの生成処理</param> /// <returns>メソッド定義</returns> public static IMethod CreateMethod(string serviceName, GrpcMethodHandlerInfo handler, IGrpcMarshallerFactory marshallerFactory) { MethodInfo m = typeof(GrpcReflection).GetMethod("CreateMethodCore", BindingFlags.Static | BindingFlags.NonPublic); return((IMethod)m.MakeGenericMethod(new Type[] { handler.RequestType, handler.ResponseType }).Invoke(null, new object[] { serviceName, handler, marshallerFactory })); }
public GrpcMethodHandlerInfo(string serviceName, MethodType methodType, Type requestType, Type responseType, MethodInfo handler, IGrpcMarshallerFactory marshallerFactory) { m_MethodType = methodType; m_RequestType = requestType; m_ResponseType = responseType; m_Handler = handler; m_ServiceName = serviceName; m_Method = GrpcReflection.CreateMethod(serviceName, this, marshallerFactory); // var srvMethod = new GrpcServiceMethod(method, requestType, responseType); }
/// <summary> /// /// </summary> /// <param name="serviceName"></param> /// <param name="serviceType"></param> /// <param name="marshallerFactory"></param> /// <returns></returns> public static IList <GrpcServiceMethod> GetGrpcMethods(string serviceName, Type serviceType, IGrpcMarshallerFactory marshallerFactory) { List <GrpcServiceMethod> methods = new List <GrpcServiceMethod>(); foreach (GrpcMethodHandlerInfo handler in GrpcReflection.EnumerateServiceMethods(serviceType)) { IMethod method = GrpcReflection.CreateMethod(serviceName, handler, marshallerFactory); methods.Add(new GrpcServiceMethod(method, handler.RequestType, handler.ResponseType)); } return(methods); }
public static IEnumerable <GrpcMethodHandlerInfo> EnumerateServiceMethods(string serviceName, Type serviceImplType, IGrpcMarshallerFactory marshallerFactory) { foreach (MethodInfo method in serviceImplType.GetMethods(BindingFlags.Public | BindingFlags.Instance)) { if (IsIgnore(method)) { continue; } if (!TryGetServiceMethodInfo(method, out MethodType methodType, out Type requestType, out Type responseType)) { continue; } yield return(new GrpcMethodHandlerInfo(serviceName, methodType, requestType, responseType, method, marshallerFactory)); } }