private MethodDescripter generateBindServicesMethod(ref ClassDescripter classDescripter, Type servicerType) { var bindServicesMethod = new MethodDescripter("BindServices", classDescripter); bindServicesMethod.Access = AccessType.Public; bindServicesMethod.SetReturnType(typeof(ServerServiceDefinition)); bindServicesMethod.AppendCode(@"return ServerServiceDefinition.CreateBuilder()"); foreach (var method in classDescripter.Methods) { if (method.Attributes.Count == 0) { continue; } var fakeMethodTypeAttribute = method.Attributes.FirstOrDefault(p => p.Name == FakeCallTypeAttributeName); if (fakeMethodTypeAttribute == null) { continue; } var callType = (CallType)int.Parse(fakeMethodTypeAttribute.Parameters[0]); bindServicesMethod.AppendCode(generateBindServicesCode(classDescripter, method, callType, servicerType)); method.Attributes.Remove(fakeMethodTypeAttribute); } bindServicesMethod.AppendCode(@" .Build();"); return(bindServicesMethod); }
private MethodDescripter generateBindServicesMethod(ref ClassDescripter classDescripter) { var bindServicesMethod = new MethodDescripter("BindServices", classDescripter); bindServicesMethod.Access = AccessType.Public; bindServicesMethod.SetReturnType(typeof(ServerServiceDefinition)); bindServicesMethod.AppendCode(@"throw new NotImplementedException();"); return(bindServicesMethod); }
private MethodDescripter generateNoGrpcMethod(ref ClassDescripter classDescripter, MethodInfo methodInfo) { var method = new MethodDescripter(methodInfo.Name, classDescripter, false); method.Access = AccessType.Public; method.SetReturnType(GetReturnName(ref classDescripter, methodInfo.ReturnType)); var parameterDescripters = new List <ParameterDescripter>(); foreach (var param in methodInfo.GetParameters()) { classDescripter.AddUsing(param.ParameterType.Namespace); method.Parameters.Add(new ParameterDescripter(GetReturnName(ref classDescripter, param.ParameterType), param.Name)); } method.AppendCode("throw new System.NotImplementedException();"); return(method); }