I am new to Grpc and I wish to make a list of value for a request and in order to do that I need a repeater. The code is shown below.
syntax = "proto3";
option csharp_namespace = "Test.Grpc.Server.Protos";
package test;
service VcaAdministrator {
rpc ForceStop (ForceStopRequest) returns (ForceStopResponse);
}
message ForceStopRequest{
repeated string Id = 1;
}
message ForceStopResponse{
bool stopped = 1;
}
I wish to pass value to the ForceStopRequest.
var cmd = new Command("ForceStop");
cmd.AddOption(new Option<string>("--id", getDefaultValue: () => "null", description:"Force stop"));
cmd.Handler = CommandHandler.Create(async (List<string> id) =>
{
var request = new ForceStopVcaRequest()
{
Id = id
};
var response = await vcaAdministratorClient.ForceStopVcaAsync(request);
Console.WriteLine($"{response.Stopped} {response.ErrorCode} {response.ErrorMessage}");
});
return cmd;
But the code above generate an error "Property or indexer 'ForceStopRequest.Id' cannot be assigned to -- it is read only." How to fix this issue?