0

我的 OperationResult.Cs 中有以下课程

 public class OperationResult
    {
        public bool Result { get; set; }
        public string Message { get; set; }
        public string ErrorMessage { get; set; }
    }

    public class OperationResult<TResponse> : OperationResult
    {
        public OperationResult() { }
        public OperationResult(TResponse response)
        {
            Response = response;
        }

        public OperationResult(OperationResult result)
        {
            Result = result.Result;
            Message = result.Message;
            ErrorMessage = result.ErrorMessage;
        }
        public TResponse Response { get; set; }
    }

现在我想像这样将这个类转换为名为 operationResult.proto 的 grpc 文件

message OperationResult{
    string Message = 1;
    string ErrorMessage = 2;
    bool Result = 3;
}

message OperationResult<Response>{
    string Message = 1;
    string ErrorMessage = 2;
    bool Result = 3;
    Response Response = 4;
}
message Response{
    Object //for example generic type 
}

我想将此文件用于 protobuf 中的每个服务,所以我想传递通用类型,如 c# 实现

4

0 回答 0