out->Print("\n");
}
-void GenerateClientStub(Printer* out, const ServiceDescriptor* service) {
- out->Print("/// <summary>Client for $servicename$</summary>\n", "servicename",
- GetServiceClassName(service));
- out->Print("public partial class $name$ : grpc::ClientBase<$name$>\n", "name",
- GetClientClassName(service));
+void GenerateClientStub(Printer* out, const ServiceDescriptor* service,
+ bool lite_client) {
+ if (!lite_client) {
+ out->Print("/// <summary>Client for $servicename$</summary>\n",
+ "servicename", GetServiceClassName(service));
+ out->Print("public partial class $name$ : grpc::ClientBase<$name$>\n",
+ "name", GetClientClassName(service));
+ } else {
+ out->Print("/// <summary>Lite client for $servicename$</summary>\n",
+ "servicename", GetServiceClassName(service));
+ out->Print("public partial class $name$ : grpc::LiteClientBase\n", "name",
+ GetClientClassName(service));
+ }
out->Print("{\n");
out->Indent();
// constructors
- out->Print(
- "/// <summary>Creates a new client for $servicename$</summary>\n"
- "/// <param name=\"channel\">The channel to use to make remote "
- "calls.</param>\n",
- "servicename", GetServiceClassName(service));
- out->Print("public $name$(grpc::Channel channel) : base(channel)\n", "name",
- GetClientClassName(service));
- out->Print("{\n");
- out->Print("}\n");
+ if (!lite_client) {
+ out->Print(
+ "/// <summary>Creates a new client for $servicename$</summary>\n"
+ "/// <param name=\"channel\">The channel to use to make remote "
+ "calls.</param>\n",
+ "servicename", GetServiceClassName(service));
+ out->Print("public $name$(grpc::Channel channel) : base(channel)\n", "name",
+ GetClientClassName(service));
+ out->Print("{\n");
+ out->Print("}\n");
+ }
out->Print(
"/// <summary>Creates a new client for $servicename$ that uses a custom "
"<c>CallInvoker</c>.</summary>\n"
GetClientClassName(service));
out->Print("{\n");
out->Print("}\n");
- out->Print(
- "/// <summary>Protected constructor to allow creation of configured "
- "clients.</summary>\n"
- "/// <param name=\"configuration\">The client configuration.</param>\n");
- out->Print(
- "protected $name$(ClientBaseConfiguration configuration)"
- " : base(configuration)\n",
- "name", GetClientClassName(service));
- out->Print("{\n");
- out->Print("}\n\n");
+ if (!lite_client) {
+ out->Print(
+ "/// <summary>Protected constructor to allow creation of configured "
+ "clients.</summary>\n"
+ "/// <param name=\"configuration\">The client "
+ "configuration.</param>\n");
+ out->Print(
+ "protected $name$(ClientBaseConfiguration configuration)"
+ " : base(configuration)\n",
+ "name", GetClientClassName(service));
+ out->Print("{\n");
+ out->Print("}\n");
+ }
+ out->Print("\n");
for (int i = 0; i < service->method_count(); i++) {
const MethodDescriptor* method = service->method(i);
}
// override NewInstance method
- out->Print(
- "/// <summary>Creates a new instance of client from given "
- "<c>ClientBaseConfiguration</c>.</summary>\n");
- out->Print(
- "protected override $name$ NewInstance(ClientBaseConfiguration "
- "configuration)\n",
- "name", GetClientClassName(service));
- out->Print("{\n");
- out->Indent();
- out->Print("return new $name$(configuration);\n", "name",
- GetClientClassName(service));
- out->Outdent();
- out->Print("}\n");
+ if (!lite_client) {
+ out->Print(
+ "/// <summary>Creates a new instance of client from given "
+ "<c>ClientBaseConfiguration</c>.</summary>\n");
+ out->Print(
+ "protected override $name$ NewInstance(ClientBaseConfiguration "
+ "configuration)\n",
+ "name", GetClientClassName(service));
+ out->Print("{\n");
+ out->Indent();
+ out->Print("return new $name$(configuration);\n", "name",
+ GetClientClassName(service));
+ out->Outdent();
+ out->Print("}\n");
+ }
out->Outdent();
out->Print("}\n");
void GenerateService(Printer* out, const ServiceDescriptor* service,
bool generate_client, bool generate_server,
- bool internal_access) {
+ bool internal_access, bool lite_client) {
GenerateDocCommentBody(out, service);
out->Print("$access_level$ static partial class $classname$\n",
"access_level", GetAccessLevel(internal_access), "classname",
GenerateServerClass(out, service);
}
if (generate_client) {
- GenerateClientStub(out, service);
+ GenerateClientStub(out, service, lite_client);
}
+
if (generate_server) {
GenerateBindServiceMethod(out, service);
GenerateBindServiceWithBinderMethod(out, service);
} // anonymous namespace
grpc::string GetServices(const FileDescriptor* file, bool generate_client,
- bool generate_server, bool internal_access) {
+ bool generate_server, bool internal_access,
+ bool lite_client) {
grpc::string output;
{
// Scope the output stream so it closes and finalizes output to the string.
}
for (int i = 0; i < file->service_count(); i++) {
GenerateService(&out, file->service(i), generate_client, generate_server,
- internal_access);
+ internal_access, lite_client);
}
if (file_namespace != "") {
out.Outdent();