aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/cpp/helloworld/greeter_async_client.cc52
-rw-r--r--examples/cpp/helloworld/greeter_async_server.cc60
-rw-r--r--examples/cpp/helloworld/greeter_client.cc24
-rw-r--r--examples/cpp/helloworld/greeter_server.cc15
-rw-r--r--examples/csharp/Greeter/Helloworld.cs617
-rw-r--r--examples/csharp/Greeter/HelloworldGrpc.cs78
-rw-r--r--examples/csharp/Greeter/packages.config11
-rw-r--r--examples/csharp/Greeter/protos/helloworld.proto52
-rw-r--r--examples/csharp/GreeterClient/Program.cs25
-rw-r--r--examples/csharp/GreeterClient/packages.config11
-rw-r--r--examples/csharp/GreeterServer/Program.cs37
-rw-r--r--examples/csharp/GreeterServer/packages.config11
-rw-r--r--examples/csharp/helloworld/.nuget/packages.config4
-rw-r--r--examples/csharp/helloworld/Greeter.sln (renamed from examples/csharp/Greeter.sln)0
-rw-r--r--examples/csharp/helloworld/Greeter/.gitignore (renamed from examples/csharp/Greeter/.gitignore)0
-rw-r--r--examples/csharp/helloworld/Greeter/Greeter.csproj (renamed from examples/csharp/Greeter/Greeter.csproj)33
-rw-r--r--examples/csharp/helloworld/Greeter/Helloworld.cs248
-rw-r--r--examples/csharp/helloworld/Greeter/HelloworldGrpc.cs89
-rw-r--r--examples/csharp/helloworld/Greeter/Properties/AssemblyInfo.cs (renamed from examples/csharp/Greeter/Properties/AssemblyInfo.cs)0
-rw-r--r--examples/csharp/helloworld/Greeter/packages.config10
-rw-r--r--examples/csharp/helloworld/GreeterClient/.gitignore (renamed from examples/csharp/GreeterClient/.gitignore)0
-rw-r--r--examples/csharp/helloworld/GreeterClient/GreeterClient.csproj (renamed from examples/csharp/GreeterClient/GreeterClient.csproj)33
-rw-r--r--examples/csharp/helloworld/GreeterClient/Program.cs24
-rw-r--r--examples/csharp/helloworld/GreeterClient/Properties/AssemblyInfo.cs (renamed from examples/csharp/GreeterClient/Properties/AssemblyInfo.cs)0
-rw-r--r--examples/csharp/helloworld/GreeterClient/packages.config10
-rw-r--r--examples/csharp/helloworld/GreeterServer/.gitignore (renamed from examples/csharp/GreeterServer/.gitignore)0
-rw-r--r--examples/csharp/helloworld/GreeterServer/GreeterServer.csproj (renamed from examples/csharp/GreeterServer/GreeterServer.csproj)33
-rw-r--r--examples/csharp/helloworld/GreeterServer/Program.cs37
-rw-r--r--examples/csharp/helloworld/GreeterServer/Properties/AssemblyInfo.cs (renamed from examples/csharp/GreeterServer/Properties/AssemblyInfo.cs)0
-rw-r--r--examples/csharp/helloworld/GreeterServer/packages.config10
-rw-r--r--examples/csharp/helloworld/README.md (renamed from examples/csharp/README.md)0
-rw-r--r--examples/csharp/helloworld/generate_protos.bat10
-rw-r--r--examples/csharp/route_guide/.nuget/packages.config2
-rw-r--r--examples/csharp/route_guide/README.md115
-rw-r--r--examples/csharp/route_guide/RouteGuide/RouteGuide.cs2033
-rw-r--r--examples/csharp/route_guide/RouteGuide/RouteGuide.csproj34
-rw-r--r--examples/csharp/route_guide/RouteGuide/RouteGuideGrpc.cs122
-rw-r--r--examples/csharp/route_guide/RouteGuide/RouteGuideUtil.cs63
-rw-r--r--examples/csharp/route_guide/RouteGuide/packages.config11
-rw-r--r--examples/csharp/route_guide/RouteGuide/protos/route_guide.proto123
-rw-r--r--examples/csharp/route_guide/RouteGuideClient/Program.cs88
-rw-r--r--examples/csharp/route_guide/RouteGuideClient/RouteGuideClient.csproj33
-rw-r--r--examples/csharp/route_guide/RouteGuideClient/packages.config11
-rw-r--r--examples/csharp/route_guide/RouteGuideServer/Program.cs16
-rw-r--r--examples/csharp/route_guide/RouteGuideServer/RouteGuideImpl.cs128
-rw-r--r--examples/csharp/route_guide/RouteGuideServer/RouteGuideServer.csproj33
-rw-r--r--examples/csharp/route_guide/RouteGuideServer/packages.config11
-rw-r--r--examples/csharp/route_guide/generate_protos.bat10
-rw-r--r--examples/node/route_guide/README.md27
-rw-r--r--examples/node/route_guide/route_guide.proto4
-rw-r--r--examples/node/route_guide/route_guide_client.js6
-rw-r--r--examples/node/route_guide/route_guide_server.js4
52 files changed, 1427 insertions, 2981 deletions
diff --git a/examples/cpp/helloworld/greeter_async_client.cc b/examples/cpp/helloworld/greeter_async_client.cc
index 605fb7fb3a..923c8ffa74 100644
--- a/examples/cpp/helloworld/greeter_async_client.cc
+++ b/examples/cpp/helloworld/greeter_async_client.cc
@@ -35,13 +35,8 @@
#include <memory>
#include <string>
-#include <grpc/grpc.h>
-#include <grpc/support/log.h>
-#include <grpc++/channel.h>
-#include <grpc++/client_context.h>
-#include <grpc++/completion_queue.h>
-#include <grpc++/create_channel.h>
-#include <grpc++/security/credentials.h>
+#include <grpc++/grpc++.h>
+
#include "helloworld.grpc.pb.h"
using grpc::Channel;
@@ -58,39 +53,72 @@ class GreeterClient {
explicit GreeterClient(std::shared_ptr<Channel> channel)
: stub_(Greeter::NewStub(channel)) {}
+ // Assambles the client's payload, sends it and presents the response back
+ // from the server.
std::string SayHello(const std::string& user) {
+ // Data we are sending to the server.
HelloRequest request;
request.set_name(user);
+
+ // Container for the data we expect from the server.
HelloReply reply;
+
+ // Context for the client. It could be used to convey extra information to
+ // the server and/or tweak certain RPC behaviors.
ClientContext context;
+
+ // The producer-consumer queue we use to communicate asynchronously with the
+ // gRPC runtime.
CompletionQueue cq;
+
+ // Storage for the status of the RPC upon completion.
Status status;
+ // stub_->AsyncSayHello() perform the RPC call, returning an instance we
+ // store in "rpc". Because we are using the asynchronous API, we need the
+ // hold on to the "rpc" instance in order to get updates on the ongoig RPC.
std::unique_ptr<ClientAsyncResponseReader<HelloReply> > rpc(
stub_->AsyncSayHello(&context, request, &cq));
+
+ // Request that, upon completion of the RPC, "reply" be updated with the
+ // server's response; "status" with the indication of whether the operation
+ // was successful. Tag the request with the integer 1.
rpc->Finish(&reply, &status, (void*)1);
void* got_tag;
bool ok = false;
+ // Block until the next result is available in the completion queue "cq".
cq.Next(&got_tag, &ok);
- GPR_ASSERT(ok);
+
+ // Verify that the result from "cq" corresponds, by its tag, our previous
+ // request.
GPR_ASSERT(got_tag == (void*)1);
+ // ... and that the request was completed successfully. Note that "ok"
+ // corresponds solely to the request for updates introduced by Finish().
+ GPR_ASSERT(ok);
+ // Act upon the status of the actual RPC.
if (status.ok()) {
return reply.message();
} else {
- return "Rpc failed";
+ return "RPC failed";
}
}
private:
+ // Out of the passed in Channel comes the stub, stored here, our view of the
+ // server's exposed services.
std::unique_ptr<Greeter::Stub> stub_;
};
int main(int argc, char** argv) {
- GreeterClient greeter(grpc::CreateChannel(
- "localhost:50051", grpc::InsecureCredentials()));
+ // Instantiate the client. It requires a channel, out of which the actual RPCs
+ // are created. This channel models a connection to an endpoint (in this case,
+ // localhost at port 50051). We indicate that the channel isn't authenticated
+ // (use of InsecureCredentials()).
+ GreeterClient greeter(
+ grpc::CreateChannel("localhost:50051", grpc::InsecureCredentials()));
std::string user("world");
- std::string reply = greeter.SayHello(user);
+ std::string reply = greeter.SayHello(user); // The actual RPC call!
std::cout << "Greeter received: " << reply << std::endl;
return 0;
diff --git a/examples/cpp/helloworld/greeter_async_server.cc b/examples/cpp/helloworld/greeter_async_server.cc
index 189c3afe6d..b2047a8ce5 100644
--- a/examples/cpp/helloworld/greeter_async_server.cc
+++ b/examples/cpp/helloworld/greeter_async_server.cc
@@ -36,13 +36,8 @@
#include <string>
#include <thread>
-#include <grpc/grpc.h>
-#include <grpc/support/log.h>
-#include <grpc++/completion_queue.h>
-#include <grpc++/security/server_credentials.h>
-#include <grpc++/server.h>
-#include <grpc++/server_builder.h>
-#include <grpc++/server_context.h>
+#include <grpc++/grpc++.h>
+
#include "helloworld.grpc.pb.h"
using grpc::Server;
@@ -59,6 +54,7 @@ class ServerImpl final {
public:
~ServerImpl() {
server_->Shutdown();
+ // Always shutdown the completion queue after the server.
cq_->Shutdown();
}
@@ -67,56 +63,102 @@ class ServerImpl final {
std::string server_address("0.0.0.0:50051");
ServerBuilder builder;
+ // Listen on the given address without any authentication mechanism.
builder.AddListeningPort(server_address, grpc::InsecureServerCredentials());
+ // Register "service_" as the instance through which we'll communicate with
+ // clients. In this case it corresponds to an *asynchronous* service.
builder.RegisterAsyncService(&service_);
+ // Get hold of the completion queue used for the asynchronous communication
+ // with the gRPC runtime.
cq_ = builder.AddCompletionQueue();
+ // Finally assemble the server.
server_ = builder.BuildAndStart();
std::cout << "Server listening on " << server_address << std::endl;
+ // Proceed to the server's main loop.
HandleRpcs();
}
private:
+ // Class encompasing the state and logic needed to serve a request.
class CallData {
public:
+ // Take in the "service" instance (in this case representing an asynchronous
+ // server) and the completion queue "cq" used for asynchronous communication
+ // with the gRPC runtime.
CallData(Greeter::AsyncService* service, ServerCompletionQueue* cq)
: service_(service), cq_(cq), responder_(&ctx_), status_(CREATE) {
+ // Invoke the serving logic right away.
Proceed();
}
void Proceed() {
if (status_ == CREATE) {
+ // As part of the initial CREATE state, we *request* that the system
+ // start processing SayHello requests. In this request, "this" acts are
+ // the tag uniquely identifying the request (so that different CallData
+ // instances can serve different requests concurrently), in this case
+ // the memory address of this CallData instance.
service_->RequestSayHello(&ctx_, &request_, &responder_, cq_, cq_,
this);
+ // Make this instance progress to the PROCESS state.
status_ = PROCESS;
} else if (status_ == PROCESS) {
+ // Spawn a new CallData instance to serve new clients while we process
+ // the one for this CallData. The instance will deallocate itself as
+ // part of its FINISH state.
new CallData(service_, cq_);
+
+ // The actual processing.
std::string prefix("Hello ");
reply_.set_message(prefix + request_.name());
+
+ // And we are done! Let the gRPC runtime know we've finished, using the
+ // memory address of this instance as the uniquely identifying tag for
+ // the event.
responder_.Finish(reply_, Status::OK, this);
status_ = FINISH;
} else {
+ GPR_ASSERT(status_ == FINISH);
+ // Once in the FINISH state, deallocate ourselves (CallData).
delete this;
}
}
private:
+ // The means of communication with the gRPC runtime for an asynchronous
+ // server.
Greeter::AsyncService* service_;
+ // The producer-consumer queue where for asynchronous server notifications.
ServerCompletionQueue* cq_;
+ // Context for the rpc, allowing to tweak aspects of it such as the use
+ // of compression, authentication, as well as to send metadata back to the
+ // client.
ServerContext ctx_;
+
+ // What we get from the client.
HelloRequest request_;
+ // What we send back to the client.
HelloReply reply_;
+
+ // The means to get back to the client.
ServerAsyncResponseWriter<HelloReply> responder_;
+
+ // Let's implement a tiny state machine with the following states.
enum CallStatus { CREATE, PROCESS, FINISH };
- CallStatus status_;
+ CallStatus status_; // The current serving state.
};
// This can be run in multiple threads if needed.
void HandleRpcs() {
+ // Spawn a new CallData instance to serve new clients.
new CallData(&service_, cq_.get());
- void* tag;
+ void* tag; // uniquely identifies a request.
bool ok;
while (true) {
+ // Block waiting to read the next event from the completion queue. The
+ // event is uniquely identified by its tag, which in this case is the
+ // memory address of a CallData instance.
cq_->Next(&tag, &ok);
GPR_ASSERT(ok);
static_cast<CallData*>(tag)->Proceed();
diff --git a/examples/cpp/helloworld/greeter_client.cc b/examples/cpp/helloworld/greeter_client.cc
index bfb7c12724..6cd8353a9f 100644
--- a/examples/cpp/helloworld/greeter_client.cc
+++ b/examples/cpp/helloworld/greeter_client.cc
@@ -35,11 +35,8 @@
#include <memory>
#include <string>
-#include <grpc/grpc.h>
-#include <grpc++/channel.h>
-#include <grpc++/client_context.h>
-#include <grpc++/create_channel.h>
-#include <grpc++/security/credentials.h>
+#include <grpc++/grpc++.h>
+
#include "helloworld.grpc.pb.h"
using grpc::Channel;
@@ -54,17 +51,28 @@ class GreeterClient {
GreeterClient(std::shared_ptr<Channel> channel)
: stub_(Greeter::NewStub(channel)) {}
+ // Assambles the client's payload, sends it and presents the response back
+ // from the server.
std::string SayHello(const std::string& user) {
+ // Data we are sending to the server.
HelloRequest request;
request.set_name(user);
+
+ // Container for the data we expect from the server.
HelloReply reply;
+
+ // Context for the client. It could be used to convey extra information to
+ // the server and/or tweak certain RPC behaviors.
ClientContext context;
+ // The actual RPC.
Status status = stub_->SayHello(&context, request, &reply);
+
+ // Act upon its status.
if (status.ok()) {
return reply.message();
} else {
- return "Rpc failed";
+ return "RPC failed";
}
}
@@ -73,6 +81,10 @@ class GreeterClient {
};
int main(int argc, char** argv) {
+ // Instantiate the client. It requires a channel, out of which the actual RPCs
+ // are created. This channel models a connection to an endpoint (in this case,
+ // localhost at port 50051). We indicate that the channel isn't authenticated
+ // (use of InsecureCredentials()).
GreeterClient greeter(
grpc::CreateChannel("localhost:50051", grpc::InsecureCredentials()));
std::string user("world");
diff --git a/examples/cpp/helloworld/greeter_server.cc b/examples/cpp/helloworld/greeter_server.cc
index b434752d87..9eab32c62b 100644
--- a/examples/cpp/helloworld/greeter_server.cc
+++ b/examples/cpp/helloworld/greeter_server.cc
@@ -35,11 +35,8 @@
#include <memory>
#include <string>
-#include <grpc/grpc.h>
-#include <grpc++/security/server_credentials.h>
-#include <grpc++/server.h>
-#include <grpc++/server_builder.h>
-#include <grpc++/server_context.h>
+#include <grpc++/grpc++.h>
+
#include "helloworld.grpc.pb.h"
using grpc::Server;
@@ -50,6 +47,7 @@ using helloworld::HelloRequest;
using helloworld::HelloReply;
using helloworld::Greeter;
+// Logic and data behind the server's behavior.
class GreeterServiceImpl final : public Greeter::Service {
Status SayHello(ServerContext* context, const HelloRequest* request,
HelloReply* reply) override {
@@ -64,10 +62,17 @@ void RunServer() {
GreeterServiceImpl service;
ServerBuilder builder;
+ // Listen on the given address without any authentication mechanism.
builder.AddListeningPort(server_address, grpc::InsecureServerCredentials());
+ // Register "service" as the instance through which we'll communicate with
+ // clients. In this case it corresponds to an *synchronous* service.
builder.RegisterService(&service);
+ // Finally assemble the server.
std::unique_ptr<Server> server(builder.BuildAndStart());
std::cout << "Server listening on " << server_address << std::endl;
+
+ // Wait for the server to shutdown. Note that some other thread must be
+ // responsible for shutting down the server for this call to ever return.
server->Wait();
}
diff --git a/examples/csharp/Greeter/Helloworld.cs b/examples/csharp/Greeter/Helloworld.cs
deleted file mode 100644
index 923a4271e9..0000000000
--- a/examples/csharp/Greeter/Helloworld.cs
+++ /dev/null
@@ -1,617 +0,0 @@
-// Generated by the protocol buffer compiler. DO NOT EDIT!
-// source: helloworld.proto
-#pragma warning disable 1591, 0612, 3021
-#region Designer generated code
-
-using pb = global::Google.ProtocolBuffers;
-using pbc = global::Google.ProtocolBuffers.Collections;
-using pbd = global::Google.ProtocolBuffers.Descriptors;
-using scg = global::System.Collections.Generic;
-namespace helloworld {
-
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- public static partial class Helloworld {
-
- #region Extension registration
- public static void RegisterAllExtensions(pb::ExtensionRegistry registry) {
- }
- #endregion
- #region Static variables
- internal static pbd::MessageDescriptor internal__static_helloworld_HelloRequest__Descriptor;
- internal static pb::FieldAccess.FieldAccessorTable<global::helloworld.HelloRequest, global::helloworld.HelloRequest.Builder> internal__static_helloworld_HelloRequest__FieldAccessorTable;
- internal static pbd::MessageDescriptor internal__static_helloworld_HelloReply__Descriptor;
- internal static pb::FieldAccess.FieldAccessorTable<global::helloworld.HelloReply, global::helloworld.HelloReply.Builder> internal__static_helloworld_HelloReply__FieldAccessorTable;
- #endregion
- #region Descriptor
- public static pbd::FileDescriptor Descriptor {
- get { return descriptor; }
- }
- private static pbd::FileDescriptor descriptor;
-
- static Helloworld() {
- byte[] descriptorData = global::System.Convert.FromBase64String(
- string.Concat(
- "ChBoZWxsb3dvcmxkLnByb3RvEgpoZWxsb3dvcmxkIhwKDEhlbGxvUmVxdWVz",
- "dBIMCgRuYW1lGAEgASgJIh0KCkhlbGxvUmVwbHkSDwoHbWVzc2FnZRgBIAEo",
- "CTJJCgdHcmVldGVyEj4KCFNheUhlbGxvEhguaGVsbG93b3JsZC5IZWxsb1Jl",
- "cXVlc3QaFi5oZWxsb3dvcmxkLkhlbGxvUmVwbHkiAEISChBpby5ncnBjLmV4",
- "YW1wbGVz"));
- pbd::FileDescriptor.InternalDescriptorAssigner assigner = delegate(pbd::FileDescriptor root) {
- descriptor = root;
- internal__static_helloworld_HelloRequest__Descriptor = Descriptor.MessageTypes[0];
- internal__static_helloworld_HelloRequest__FieldAccessorTable =
- new pb::FieldAccess.FieldAccessorTable<global::helloworld.HelloRequest, global::helloworld.HelloRequest.Builder>(internal__static_helloworld_HelloRequest__Descriptor,
- new string[] { "Name", });
- internal__static_helloworld_HelloReply__Descriptor = Descriptor.MessageTypes[1];
- internal__static_helloworld_HelloReply__FieldAccessorTable =
- new pb::FieldAccess.FieldAccessorTable<global::helloworld.HelloReply, global::helloworld.HelloReply.Builder>(internal__static_helloworld_HelloReply__Descriptor,
- new string[] { "Message", });
- pb::ExtensionRegistry registry = pb::ExtensionRegistry.CreateInstance();
- RegisterAllExtensions(registry);
- return registry;
- };
- pbd::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData,
- new pbd::FileDescriptor[] {
- }, assigner);
- }
- #endregion
-
- }
- #region Messages
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- public sealed partial class HelloRequest : pb::GeneratedMessage<HelloRequest, HelloRequest.Builder> {
- private HelloRequest() { }
- private static readonly HelloRequest defaultInstance = new HelloRequest().MakeReadOnly();
- private static readonly string[] _helloRequestFieldNames = new string[] { "name" };
- private static readonly uint[] _helloRequestFieldTags = new uint[] { 10 };
- public static HelloRequest DefaultInstance {
- get { return defaultInstance; }
- }
-
- public override HelloRequest DefaultInstanceForType {
- get { return DefaultInstance; }
- }
-
- protected override HelloRequest ThisMessage {
- get { return this; }
- }
-
- public static pbd::MessageDescriptor Descriptor {
- get { return global::helloworld.Helloworld.internal__static_helloworld_HelloRequest__Descriptor; }
- }
-
- protected override pb::FieldAccess.FieldAccessorTable<HelloRequest, HelloRequest.Builder> InternalFieldAccessors {
- get { return global::helloworld.Helloworld.internal__static_helloworld_HelloRequest__FieldAccessorTable; }
- }
-
- public const int NameFieldNumber = 1;
- private bool hasName;
- private string name_ = "";
- public bool HasName {
- get { return hasName; }
- }
- public string Name {
- get { return name_; }
- }
-
- public override bool IsInitialized {
- get {
- return true;
- }
- }
-
- public override void WriteTo(pb::ICodedOutputStream output) {
- CalcSerializedSize();
- string[] field_names = _helloRequestFieldNames;
- if (hasName) {
- output.WriteString(1, field_names[0], Name);
- }
- UnknownFields.WriteTo(output);
- }
-
- private int memoizedSerializedSize = -1;
- public override int SerializedSize {
- get {
- int size = memoizedSerializedSize;
- if (size != -1) return size;
- return CalcSerializedSize();
- }
- }
-
- private int CalcSerializedSize() {
- int size = memoizedSerializedSize;
- if (size != -1) return size;
-
- size = 0;
- if (hasName) {
- size += pb::CodedOutputStream.ComputeStringSize(1, Name);
- }
- size += UnknownFields.SerializedSize;
- memoizedSerializedSize = size;
- return size;
- }
- public static HelloRequest ParseFrom(pb::ByteString data) {
- return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed();
- }
- public static HelloRequest ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) {
- return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed();
- }
- public static HelloRequest ParseFrom(byte[] data) {
- return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed();
- }
- public static HelloRequest ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) {
- return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed();
- }
- public static HelloRequest ParseFrom(global::System.IO.Stream input) {
- return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed();
- }
- public static HelloRequest ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) {
- return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
- }
- public static HelloRequest ParseDelimitedFrom(global::System.IO.Stream input) {
- return CreateBuilder().MergeDelimitedFrom(input).BuildParsed();
- }
- public static HelloRequest ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) {
- return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed();
- }
- public static HelloRequest ParseFrom(pb::ICodedInputStream input) {
- return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed();
- }
- public static HelloRequest ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
- return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
- }
- private HelloRequest MakeReadOnly() {
- return this;
- }
-
- public static Builder CreateBuilder() { return new Builder(); }
- public override Builder ToBuilder() { return CreateBuilder(this); }
- public override Builder CreateBuilderForType() { return new Builder(); }
- public static Builder CreateBuilder(HelloRequest prototype) {
- return new Builder(prototype);
- }
-
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- public sealed partial class Builder : pb::GeneratedBuilder<HelloRequest, Builder> {
- protected override Builder ThisBuilder {
- get { return this; }
- }
- public Builder() {
- result = DefaultInstance;
- resultIsReadOnly = true;
- }
- internal Builder(HelloRequest cloneFrom) {
- result = cloneFrom;
- resultIsReadOnly = true;
- }
-
- private bool resultIsReadOnly;
- private HelloRequest result;
-
- private HelloRequest PrepareBuilder() {
- if (resultIsReadOnly) {
- HelloRequest original = result;
- result = new HelloRequest();
- resultIsReadOnly = false;
- MergeFrom(original);
- }
- return result;
- }
-
- public override bool IsInitialized {
- get { return result.IsInitialized; }
- }
-
- protected override HelloRequest MessageBeingBuilt {
- get { return PrepareBuilder(); }
- }
-
- public override Builder Clear() {
- result = DefaultInstance;
- resultIsReadOnly = true;
- return this;
- }
-
- public override Builder Clone() {
- if (resultIsReadOnly) {
- return new Builder(result);
- } else {
- return new Builder().MergeFrom(result);
- }
- }
-
- public override pbd::MessageDescriptor DescriptorForType {
- get { return global::helloworld.HelloRequest.Descriptor; }
- }
-
- public override HelloRequest DefaultInstanceForType {
- get { return global::helloworld.HelloRequest.DefaultInstance; }
- }
-
- public override HelloRequest BuildPartial() {
- if (resultIsReadOnly) {
- return result;
- }
- resultIsReadOnly = true;
- return result.MakeReadOnly();
- }
-
- public override Builder MergeFrom(pb::IMessage other) {
- if (other is HelloRequest) {
- return MergeFrom((HelloRequest) other);
- } else {
- base.MergeFrom(other);
- return this;
- }
- }
-
- public override Builder MergeFrom(HelloRequest other) {
- if (other == global::helloworld.HelloRequest.DefaultInstance) return this;
- PrepareBuilder();
- if (other.HasName) {
- Name = other.Name;
- }
- this.MergeUnknownFields(other.UnknownFields);
- return this;
- }
-
- public override Builder MergeFrom(pb::ICodedInputStream input) {
- return MergeFrom(input, pb::ExtensionRegistry.Empty);
- }
-
- public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
- PrepareBuilder();
- pb::UnknownFieldSet.Builder unknownFields = null;
- uint tag;
- string field_name;
- while (input.ReadTag(out tag, out field_name)) {
- if(tag == 0 && field_name != null) {
- int field_ordinal = global::System.Array.BinarySearch(_helloRequestFieldNames, field_name, global::System.StringComparer.Ordinal);
- if(field_ordinal >= 0)
- tag = _helloRequestFieldTags[field_ordinal];
- else {
- if (unknownFields == null) {
- unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
- }
- ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
- continue;
- }
- }
- switch (tag) {
- case 0: {
- throw pb::InvalidProtocolBufferException.InvalidTag();
- }
- default: {
- if (pb::WireFormat.IsEndGroupTag(tag)) {
- if (unknownFields != null) {
- this.UnknownFields = unknownFields.Build();
- }
- return this;
- }
- if (unknownFields == null) {
- unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
- }
- ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
- break;
- }
- case 10: {
- result.hasName = input.ReadString(ref result.name_);
- break;
- }
- }
- }
-
- if (unknownFields != null) {
- this.UnknownFields = unknownFields.Build();
- }
- return this;
- }
-
-
- public bool HasName {
- get { return result.hasName; }
- }
- public string Name {
- get { return result.Name; }
- set { SetName(value); }
- }
- public Builder SetName(string value) {
- pb::ThrowHelper.ThrowIfNull(value, "value");
- PrepareBuilder();
- result.hasName = true;
- result.name_ = value;
- return this;
- }
- public Builder ClearName() {
- PrepareBuilder();
- result.hasName = false;
- result.name_ = "";
- return this;
- }
- }
- static HelloRequest() {
- object.ReferenceEquals(global::helloworld.Helloworld.Descriptor, null);
- }
- }
-
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- public sealed partial class HelloReply : pb::GeneratedMessage<HelloReply, HelloReply.Builder> {
- private HelloReply() { }
- private static readonly HelloReply defaultInstance = new HelloReply().MakeReadOnly();
- private static readonly string[] _helloReplyFieldNames = new string[] { "message" };
- private static readonly uint[] _helloReplyFieldTags = new uint[] { 10 };
- public static HelloReply DefaultInstance {
- get { return defaultInstance; }
- }
-
- public override HelloReply DefaultInstanceForType {
- get { return DefaultInstance; }
- }
-
- protected override HelloReply ThisMessage {
- get { return this; }
- }
-
- public static pbd::MessageDescriptor Descriptor {
- get { return global::helloworld.Helloworld.internal__static_helloworld_HelloReply__Descriptor; }
- }
-
- protected override pb::FieldAccess.FieldAccessorTable<HelloReply, HelloReply.Builder> InternalFieldAccessors {
- get { return global::helloworld.Helloworld.internal__static_helloworld_HelloReply__FieldAccessorTable; }
- }
-
- public const int MessageFieldNumber = 1;
- private bool hasMessage;
- private string message_ = "";
- public bool HasMessage {
- get { return hasMessage; }
- }
- public string Message {
- get { return message_; }
- }
-
- public override bool IsInitialized {
- get {
- return true;
- }
- }
-
- public override void WriteTo(pb::ICodedOutputStream output) {
- CalcSerializedSize();
- string[] field_names = _helloReplyFieldNames;
- if (hasMessage) {
- output.WriteString(1, field_names[0], Message);
- }
- UnknownFields.WriteTo(output);
- }
-
- private int memoizedSerializedSize = -1;
- public override int SerializedSize {
- get {
- int size = memoizedSerializedSize;
- if (size != -1) return size;
- return CalcSerializedSize();
- }
- }
-
- private int CalcSerializedSize() {
- int size = memoizedSerializedSize;
- if (size != -1) return size;
-
- size = 0;
- if (hasMessage) {
- size += pb::CodedOutputStream.ComputeStringSize(1, Message);
- }
- size += UnknownFields.SerializedSize;
- memoizedSerializedSize = size;
- return size;
- }
- public static HelloReply ParseFrom(pb::ByteString data) {
- return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed();
- }
- public static HelloReply ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) {
- return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed();
- }
- public static HelloReply ParseFrom(byte[] data) {
- return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed();
- }
- public static HelloReply ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) {
- return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed();
- }
- public static HelloReply ParseFrom(global::System.IO.Stream input) {
- return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed();
- }
- public static HelloReply ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) {
- return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
- }
- public static HelloReply ParseDelimitedFrom(global::System.IO.Stream input) {
- return CreateBuilder().MergeDelimitedFrom(input).BuildParsed();
- }
- public static HelloReply ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) {
- return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed();
- }
- public static HelloReply ParseFrom(pb::ICodedInputStream input) {
- return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed();
- }
- public static HelloReply ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
- return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
- }
- private HelloReply MakeReadOnly() {
- return this;
- }
-
- public static Builder CreateBuilder() { return new Builder(); }
- public override Builder ToBuilder() { return CreateBuilder(this); }
- public override Builder CreateBuilderForType() { return new Builder(); }
- public static Builder CreateBuilder(HelloReply prototype) {
- return new Builder(prototype);
- }
-
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- public sealed partial class Builder : pb::GeneratedBuilder<HelloReply, Builder> {
- protected override Builder ThisBuilder {
- get { return this; }
- }
- public Builder() {
- result = DefaultInstance;
- resultIsReadOnly = true;
- }
- internal Builder(HelloReply cloneFrom) {
- result = cloneFrom;
- resultIsReadOnly = true;
- }
-
- private bool resultIsReadOnly;
- private HelloReply result;
-
- private HelloReply PrepareBuilder() {
- if (resultIsReadOnly) {
- HelloReply original = result;
- result = new HelloReply();
- resultIsReadOnly = false;
- MergeFrom(original);
- }
- return result;
- }
-
- public override bool IsInitialized {
- get { return result.IsInitialized; }
- }
-
- protected override HelloReply MessageBeingBuilt {
- get { return PrepareBuilder(); }
- }
-
- public override Builder Clear() {
- result = DefaultInstance;
- resultIsReadOnly = true;
- return this;
- }
-
- public override Builder Clone() {
- if (resultIsReadOnly) {
- return new Builder(result);
- } else {
- return new Builder().MergeFrom(result);
- }
- }
-
- public override pbd::MessageDescriptor DescriptorForType {
- get { return global::helloworld.HelloReply.Descriptor; }
- }
-
- public override HelloReply DefaultInstanceForType {
- get { return global::helloworld.HelloReply.DefaultInstance; }
- }
-
- public override HelloReply BuildPartial() {
- if (resultIsReadOnly) {
- return result;
- }
- resultIsReadOnly = true;
- return result.MakeReadOnly();
- }
-
- public override Builder MergeFrom(pb::IMessage other) {
- if (other is HelloReply) {
- return MergeFrom((HelloReply) other);
- } else {
- base.MergeFrom(other);
- return this;
- }
- }
-
- public override Builder MergeFrom(HelloReply other) {
- if (other == global::helloworld.HelloReply.DefaultInstance) return this;
- PrepareBuilder();
- if (other.HasMessage) {
- Message = other.Message;
- }
- this.MergeUnknownFields(other.UnknownFields);
- return this;
- }
-
- public override Builder MergeFrom(pb::ICodedInputStream input) {
- return MergeFrom(input, pb::ExtensionRegistry.Empty);
- }
-
- public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
- PrepareBuilder();
- pb::UnknownFieldSet.Builder unknownFields = null;
- uint tag;
- string field_name;
- while (input.ReadTag(out tag, out field_name)) {
- if(tag == 0 && field_name != null) {
- int field_ordinal = global::System.Array.BinarySearch(_helloReplyFieldNames, field_name, global::System.StringComparer.Ordinal);
- if(field_ordinal >= 0)
- tag = _helloReplyFieldTags[field_ordinal];
- else {
- if (unknownFields == null) {
- unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
- }
- ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
- continue;
- }
- }
- switch (tag) {
- case 0: {
- throw pb::InvalidProtocolBufferException.InvalidTag();
- }
- default: {
- if (pb::WireFormat.IsEndGroupTag(tag)) {
- if (unknownFields != null) {
- this.UnknownFields = unknownFields.Build();
- }
- return this;
- }
- if (unknownFields == null) {
- unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
- }
- ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
- break;
- }
- case 10: {
- result.hasMessage = input.ReadString(ref result.message_);
- break;
- }
- }
- }
-
- if (unknownFields != null) {
- this.UnknownFields = unknownFields.Build();
- }
- return this;
- }
-
-
- public bool HasMessage {
- get { return result.hasMessage; }
- }
- public string Message {
- get { return result.Message; }
- set { SetMessage(value); }
- }
- public Builder SetMessage(string value) {
- pb::ThrowHelper.ThrowIfNull(value, "value");
- PrepareBuilder();
- result.hasMessage = true;
- result.message_ = value;
- return this;
- }
- public Builder ClearMessage() {
- PrepareBuilder();
- result.hasMessage = false;
- result.message_ = "";
- return this;
- }
- }
- static HelloReply() {
- object.ReferenceEquals(global::helloworld.Helloworld.Descriptor, null);
- }
- }
-
- #endregion
-
-}
-
-#endregion Designer generated code
diff --git a/examples/csharp/Greeter/HelloworldGrpc.cs b/examples/csharp/Greeter/HelloworldGrpc.cs
deleted file mode 100644
index 1ca9d2899b..0000000000
--- a/examples/csharp/Greeter/HelloworldGrpc.cs
+++ /dev/null
@@ -1,78 +0,0 @@
-// Generated by the protocol buffer compiler. DO NOT EDIT!
-// source: helloworld.proto
-#region Designer generated code
-
-using System;
-using System.Threading;
-using System.Threading.Tasks;
-using Grpc.Core;
-
-namespace helloworld {
- public static class Greeter
- {
- static readonly string __ServiceName = "helloworld.Greeter";
-
- static readonly Marshaller<global::helloworld.HelloRequest> __Marshaller_HelloRequest = Marshallers.Create((arg) => arg.ToByteArray(), global::helloworld.HelloRequest.ParseFrom);
- static readonly Marshaller<global::helloworld.HelloReply> __Marshaller_HelloReply = Marshallers.Create((arg) => arg.ToByteArray(), global::helloworld.HelloReply.ParseFrom);
-
- static readonly Method<global::helloworld.HelloRequest, global::helloworld.HelloReply> __Method_SayHello = new Method<global::helloworld.HelloRequest, global::helloworld.HelloReply>(
- MethodType.Unary,
- "SayHello",
- __Marshaller_HelloRequest,
- __Marshaller_HelloReply);
-
- // client-side stub interface
- public interface IGreeterClient
- {
- global::helloworld.HelloReply SayHello(global::helloworld.HelloRequest request, CancellationToken token = default(CancellationToken));
- Task<global::helloworld.HelloReply> SayHelloAsync(global::helloworld.HelloRequest request, CancellationToken token = default(CancellationToken));
- }
-
- // server-side interface
- public interface IGreeter
- {
- Task<global::helloworld.HelloReply> SayHello(ServerCallContext context, global::helloworld.HelloRequest request);
- }
-
- // client stub
- public class GreeterClient : AbstractStub<GreeterClient, StubConfiguration>, IGreeterClient
- {
- public GreeterClient(Channel channel) : this(channel, StubConfiguration.Default)
- {
- }
- public GreeterClient(Channel channel, StubConfiguration config) : base(channel, config)
- {
- }
- public global::helloworld.HelloReply SayHello(global::helloworld.HelloRequest request, CancellationToken token = default(CancellationToken))
- {
- var call = CreateCall(__ServiceName, __Method_SayHello);
- return Calls.BlockingUnaryCall(call, request, token);
- }
- public Task<global::helloworld.HelloReply> SayHelloAsync(global::helloworld.HelloRequest request, CancellationToken token = default(CancellationToken))
- {
- var call = CreateCall(__ServiceName, __Method_SayHello);
- return Calls.AsyncUnaryCall(call, request, token);
- }
- }
-
- // creates service definition that can be registered with a server
- public static ServerServiceDefinition BindService(IGreeter serviceImpl)
- {
- return ServerServiceDefinition.CreateBuilder(__ServiceName)
- .AddMethod(__Method_SayHello, serviceImpl.SayHello).Build();
- }
-
- // creates a new client stub
- public static IGreeterClient NewStub(Channel channel)
- {
- return new GreeterClient(channel);
- }
-
- // creates a new client stub
- public static IGreeterClient NewStub(Channel channel, StubConfiguration config)
- {
- return new GreeterClient(channel, config);
- }
- }
-}
-#endregion
diff --git a/examples/csharp/Greeter/packages.config b/examples/csharp/Greeter/packages.config
deleted file mode 100644
index 5922553bc3..0000000000
--- a/examples/csharp/Greeter/packages.config
+++ /dev/null
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<packages>
- <package id="Google.ProtocolBuffers" version="2.4.1.555" targetFramework="net45" />
- <package id="Grpc" version="0.6.0" targetFramework="net45" />
- <package id="Grpc.Core" version="0.6.0" targetFramework="net45" />
- <package id="grpc.dependencies.openssl.redist" version="1.0.2.2" targetFramework="net45" />
- <package id="grpc.dependencies.zlib.redist" version="1.2.8.9" targetFramework="net45" />
- <package id="grpc.native.csharp_ext" version="0.10.0" targetFramework="net45" />
- <package id="Ix-Async" version="1.2.3" targetFramework="net45" />
- <package id="System.Collections.Immutable" version="1.1.36" targetFramework="net45" />
-</packages> \ No newline at end of file
diff --git a/examples/csharp/Greeter/protos/helloworld.proto b/examples/csharp/Greeter/protos/helloworld.proto
deleted file mode 100644
index e02ebd94e7..0000000000
--- a/examples/csharp/Greeter/protos/helloworld.proto
+++ /dev/null
@@ -1,52 +0,0 @@
-// Copyright 2015, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-// TODO(jtattermusch): as of now, C# protobufs don't officially support
-// proto3.
-syntax = "proto2";
-
-option java_package = "io.grpc.examples";
-
-package helloworld;
-
-// The greeting service definition.
-service Greeter {
- // Sends a greeting
- rpc SayHello (HelloRequest) returns (HelloReply) {}
-}
-
-// The request message containing the user's name.
-message HelloRequest {
- optional string name = 1;
-}
-
-// The response message containing the greetings
-message HelloReply {
- optional string message = 1;
-}
diff --git a/examples/csharp/GreeterClient/Program.cs b/examples/csharp/GreeterClient/Program.cs
deleted file mode 100644
index 61c29762b1..0000000000
--- a/examples/csharp/GreeterClient/Program.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using System;
-using Grpc.Core;
-using helloworld;
-
-namespace GreeterClient
-{
- class ClientMainClass
- {
- public static void Main(string[] args)
- {
- GrpcEnvironment.Initialize();
-
- using (Channel channel = new Channel("127.0.0.1:50051"))
- {
- var client = Greeter.NewStub(channel);
- String user = "you";
-
- var reply = client.SayHello(new HelloRequest.Builder { Name = user }.Build());
- Console.WriteLine("Greeting: " + reply.Message);
- }
-
- GrpcEnvironment.Shutdown();
- }
- }
-}
diff --git a/examples/csharp/GreeterClient/packages.config b/examples/csharp/GreeterClient/packages.config
deleted file mode 100644
index 5922553bc3..0000000000
--- a/examples/csharp/GreeterClient/packages.config
+++ /dev/null
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<packages>
- <package id="Google.ProtocolBuffers" version="2.4.1.555" targetFramework="net45" />
- <package id="Grpc" version="0.6.0" targetFramework="net45" />
- <package id="Grpc.Core" version="0.6.0" targetFramework="net45" />
- <package id="grpc.dependencies.openssl.redist" version="1.0.2.2" targetFramework="net45" />
- <package id="grpc.dependencies.zlib.redist" version="1.2.8.9" targetFramework="net45" />
- <package id="grpc.native.csharp_ext" version="0.10.0" targetFramework="net45" />
- <package id="Ix-Async" version="1.2.3" targetFramework="net45" />
- <package id="System.Collections.Immutable" version="1.1.36" targetFramework="net45" />
-</packages> \ No newline at end of file
diff --git a/examples/csharp/GreeterServer/Program.cs b/examples/csharp/GreeterServer/Program.cs
deleted file mode 100644
index 9482797c3b..0000000000
--- a/examples/csharp/GreeterServer/Program.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-using System;
-using System.Threading.Tasks;
-using Grpc.Core;
-using helloworld;
-
-namespace GreeterServer
-{
- class GreeterImpl : Greeter.IGreeter
- {
- // Server side handler of the SayHello RPC
- public Task<HelloReply> SayHello(ServerCallContext context, HelloRequest request)
- {
- var reply = new HelloReply.Builder { Message = "Hello " + request.Name }.Build();
- return Task.FromResult(reply);
- }
- }
-
- class ServerMainClass
- {
- public static void Main(string[] args)
- {
- GrpcEnvironment.Initialize();
-
- Server server = new Server();
- server.AddServiceDefinition(Greeter.BindService(new GreeterImpl()));
- int port = server.AddListeningPort("localhost", 50051);
- server.Start();
-
- Console.WriteLine("Greeter server listening on port " + port);
- Console.WriteLine("Press any key to stop the server...");
- Console.ReadKey();
-
- server.ShutdownAsync().Wait();
- GrpcEnvironment.Shutdown();
- }
- }
-}
diff --git a/examples/csharp/GreeterServer/packages.config b/examples/csharp/GreeterServer/packages.config
deleted file mode 100644
index 5922553bc3..0000000000
--- a/examples/csharp/GreeterServer/packages.config
+++ /dev/null
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<packages>
- <package id="Google.ProtocolBuffers" version="2.4.1.555" targetFramework="net45" />
- <package id="Grpc" version="0.6.0" targetFramework="net45" />
- <package id="Grpc.Core" version="0.6.0" targetFramework="net45" />
- <package id="grpc.dependencies.openssl.redist" version="1.0.2.2" targetFramework="net45" />
- <package id="grpc.dependencies.zlib.redist" version="1.2.8.9" targetFramework="net45" />
- <package id="grpc.native.csharp_ext" version="0.10.0" targetFramework="net45" />
- <package id="Ix-Async" version="1.2.3" targetFramework="net45" />
- <package id="System.Collections.Immutable" version="1.1.36" targetFramework="net45" />
-</packages> \ No newline at end of file
diff --git a/examples/csharp/helloworld/.nuget/packages.config b/examples/csharp/helloworld/.nuget/packages.config
new file mode 100644
index 0000000000..e2879c1893
--- /dev/null
+++ b/examples/csharp/helloworld/.nuget/packages.config
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+ <package id="Grpc.Tools" version="0.7.0" />
+</packages> \ No newline at end of file
diff --git a/examples/csharp/Greeter.sln b/examples/csharp/helloworld/Greeter.sln
index 9430e94de9..9430e94de9 100644
--- a/examples/csharp/Greeter.sln
+++ b/examples/csharp/helloworld/Greeter.sln
diff --git a/examples/csharp/Greeter/.gitignore b/examples/csharp/helloworld/Greeter/.gitignore
index 1746e3269e..1746e3269e 100644
--- a/examples/csharp/Greeter/.gitignore
+++ b/examples/csharp/helloworld/Greeter/.gitignore
diff --git a/examples/csharp/Greeter/Greeter.csproj b/examples/csharp/helloworld/Greeter/Greeter.csproj
index b8f965dbd2..3d92c4bf25 100644
--- a/examples/csharp/Greeter/Greeter.csproj
+++ b/examples/csharp/helloworld/Greeter/Greeter.csproj
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.props" Condition="Exists('..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.props')" />
- <Import Project="..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.props" Condition="Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.props')" />
+ <Import Project="..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props" Condition="Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props')" />
+ <Import Project="..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props" Condition="Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props')" />
<Import Project="..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.props" Condition="Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -13,7 +13,7 @@
<RootNamespace>Greeter</RootNamespace>
<AssemblyName>Greeter</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
- <NuGetPackageImportStamp>927432a0</NuGetPackageImportStamp>
+ <NuGetPackageImportStamp>3ef64a6a</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@@ -34,21 +34,14 @@
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<ItemGroup>
- <Reference Include="Google.ProtocolBuffers">
- <HintPath>..\packages\Google.ProtocolBuffers.2.4.1.555\lib\net40\Google.ProtocolBuffers.dll</HintPath>
+ <Reference Include="Google.Protobuf">
+ <HintPath>..\packages\Google.Protobuf.3.0.0-alpha4\lib\portable-net45+netcore45+wpa81+wp8\Google.Protobuf.dll</HintPath>
</Reference>
- <Reference Include="Google.ProtocolBuffers.Serialization">
- <HintPath>..\packages\Google.ProtocolBuffers.2.4.1.555\lib\net40\Google.ProtocolBuffers.Serialization.dll</HintPath>
- </Reference>
- <Reference Include="Grpc.Core, Version=0.6.5668.37363, Culture=neutral, processorArchitecture=MSIL">
+ <Reference Include="Grpc.Core, Version=0.7.0.0, Culture=neutral, PublicKeyToken=d754f35622e28bad, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\Grpc.Core.0.6.0\lib\net45\Grpc.Core.dll</HintPath>
+ <HintPath>..\packages\Grpc.Core.0.7.0\lib\net45\Grpc.Core.dll</HintPath>
</Reference>
<Reference Include="System" />
- <Reference Include="System.Collections.Immutable, Version=1.1.36.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\System.Collections.Immutable.1.1.36\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll</HintPath>
- </Reference>
<Reference Include="System.Interactive.Async">
<HintPath>..\packages\Ix-Async.1.2.3\lib\net45\System.Interactive.Async.dll</HintPath>
</Reference>
@@ -70,12 +63,12 @@
</PropertyGroup>
<Error Condition="!Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.props'))" />
<Error Condition="!Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets'))" />
- <Error Condition="!Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.props'))" />
- <Error Condition="!Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.targets'))" />
- <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.props'))" />
- <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.targets'))" />
+ <Error Condition="!Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props'))" />
+ <Error Condition="!Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets'))" />
+ <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props'))" />
+ <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets'))" />
</Target>
<Import Project="..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets" Condition="Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets')" />
- <Import Project="..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.targets" Condition="Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.targets')" />
- <Import Project="..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.targets" Condition="Exists('..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.targets')" />
+ <Import Project="..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets" Condition="Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets')" />
+ <Import Project="..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets" Condition="Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets')" />
</Project> \ No newline at end of file
diff --git a/examples/csharp/helloworld/Greeter/Helloworld.cs b/examples/csharp/helloworld/Greeter/Helloworld.cs
new file mode 100644
index 0000000000..668165a6ce
--- /dev/null
+++ b/examples/csharp/helloworld/Greeter/Helloworld.cs
@@ -0,0 +1,248 @@
+// Generated by the protocol buffer compiler. DO NOT EDIT!
+// source: helloworld.proto
+#pragma warning disable 1591, 0612, 3021
+#region Designer generated code
+
+using pb = global::Google.Protobuf;
+using pbc = global::Google.Protobuf.Collections;
+using pbr = global::Google.Protobuf.Reflection;
+using scg = global::System.Collections.Generic;
+namespace Helloworld {
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ public static partial class Helloworld {
+
+ #region Descriptor
+ public static pbr::FileDescriptor Descriptor {
+ get { return descriptor; }
+ }
+ private static pbr::FileDescriptor descriptor;
+
+ static Helloworld() {
+ byte[] descriptorData = global::System.Convert.FromBase64String(
+ string.Concat(
+ "ChBoZWxsb3dvcmxkLnByb3RvEgpoZWxsb3dvcmxkIhwKDEhlbGxvUmVxdWVz",
+ "dBIMCgRuYW1lGAEgASgJIh0KCkhlbGxvUmVwbHkSDwoHbWVzc2FnZRgBIAEo",
+ "CTJJCgdHcmVldGVyEj4KCFNheUhlbGxvEhguaGVsbG93b3JsZC5IZWxsb1Jl",
+ "cXVlc3QaFi5oZWxsb3dvcmxkLkhlbGxvUmVwbHkiAEIYChBpby5ncnBjLmV4",
+ "YW1wbGVzogIDSExXYgZwcm90bzM="));
+ descriptor = pbr::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData,
+ new pbr::FileDescriptor[] { },
+ new pbr::GeneratedCodeInfo(null, new pbr::GeneratedCodeInfo[] {
+ new pbr::GeneratedCodeInfo(typeof(global::Helloworld.HelloRequest), new[]{ "Name" }, null, null, null),
+ new pbr::GeneratedCodeInfo(typeof(global::Helloworld.HelloReply), new[]{ "Message" }, null, null, null)
+ }));
+ }
+ #endregion
+
+ }
+ #region Messages
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ public sealed partial class HelloRequest : pb::IMessage<HelloRequest> {
+ private static readonly pb::MessageParser<HelloRequest> _parser = new pb::MessageParser<HelloRequest>(() => new HelloRequest());
+ public static pb::MessageParser<HelloRequest> Parser { get { return _parser; } }
+
+ public static pbr::MessageDescriptor Descriptor {
+ get { return global::Helloworld.Helloworld.Descriptor.MessageTypes[0]; }
+ }
+
+ pbr::MessageDescriptor pb::IMessage.Descriptor {
+ get { return Descriptor; }
+ }
+
+ public HelloRequest() {
+ OnConstruction();
+ }
+
+ partial void OnConstruction();
+
+ public HelloRequest(HelloRequest other) : this() {
+ name_ = other.name_;
+ }
+
+ public HelloRequest Clone() {
+ return new HelloRequest(this);
+ }
+
+ public const int NameFieldNumber = 1;
+ private string name_ = "";
+ public string Name {
+ get { return name_; }
+ set {
+ name_ = pb::Preconditions.CheckNotNull(value, "value");
+ }
+ }
+
+ public override bool Equals(object other) {
+ return Equals(other as HelloRequest);
+ }
+
+ public bool Equals(HelloRequest other) {
+ if (ReferenceEquals(other, null)) {
+ return false;
+ }
+ if (ReferenceEquals(other, this)) {
+ return true;
+ }
+ if (Name != other.Name) return false;
+ return true;
+ }
+
+ public override int GetHashCode() {
+ int hash = 1;
+ if (Name.Length != 0) hash ^= Name.GetHashCode();
+ return hash;
+ }
+
+ public override string ToString() {
+ return pb::JsonFormatter.Default.Format(this);
+ }
+
+ public void WriteTo(pb::CodedOutputStream output) {
+ if (Name.Length != 0) {
+ output.WriteRawTag(10);
+ output.WriteString(Name);
+ }
+ }
+
+ public int CalculateSize() {
+ int size = 0;
+ if (Name.Length != 0) {
+ size += 1 + pb::CodedOutputStream.ComputeStringSize(Name);
+ }
+ return size;
+ }
+
+ public void MergeFrom(HelloRequest other) {
+ if (other == null) {
+ return;
+ }
+ if (other.Name.Length != 0) {
+ Name = other.Name;
+ }
+ }
+
+ public void MergeFrom(pb::CodedInputStream input) {
+ uint tag;
+ while ((tag = input.ReadTag()) != 0) {
+ switch(tag) {
+ default:
+ input.SkipLastField();
+ break;
+ case 10: {
+ Name = input.ReadString();
+ break;
+ }
+ }
+ }
+ }
+
+ }
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ public sealed partial class HelloReply : pb::IMessage<HelloReply> {
+ private static readonly pb::MessageParser<HelloReply> _parser = new pb::MessageParser<HelloReply>(() => new HelloReply());
+ public static pb::MessageParser<HelloReply> Parser { get { return _parser; } }
+
+ public static pbr::MessageDescriptor Descriptor {
+ get { return global::Helloworld.Helloworld.Descriptor.MessageTypes[1]; }
+ }
+
+ pbr::MessageDescriptor pb::IMessage.Descriptor {
+ get { return Descriptor; }
+ }
+
+ public HelloReply() {
+ OnConstruction();
+ }
+
+ partial void OnConstruction();
+
+ public HelloReply(HelloReply other) : this() {
+ message_ = other.message_;
+ }
+
+ public HelloReply Clone() {
+ return new HelloReply(this);
+ }
+
+ public const int MessageFieldNumber = 1;
+ private string message_ = "";
+ public string Message {
+ get { return message_; }
+ set {
+ message_ = pb::Preconditions.CheckNotNull(value, "value");
+ }
+ }
+
+ public override bool Equals(object other) {
+ return Equals(other as HelloReply);
+ }
+
+ public bool Equals(HelloReply other) {
+ if (ReferenceEquals(other, null)) {
+ return false;
+ }
+ if (ReferenceEquals(other, this)) {
+ return true;
+ }
+ if (Message != other.Message) return false;
+ return true;
+ }
+
+ public override int GetHashCode() {
+ int hash = 1;
+ if (Message.Length != 0) hash ^= Message.GetHashCode();
+ return hash;
+ }
+
+ public override string ToString() {
+ return pb::JsonFormatter.Default.Format(this);
+ }
+
+ public void WriteTo(pb::CodedOutputStream output) {
+ if (Message.Length != 0) {
+ output.WriteRawTag(10);
+ output.WriteString(Message);
+ }
+ }
+
+ public int CalculateSize() {
+ int size = 0;
+ if (Message.Length != 0) {
+ size += 1 + pb::CodedOutputStream.ComputeStringSize(Message);
+ }
+ return size;
+ }
+
+ public void MergeFrom(HelloReply other) {
+ if (other == null) {
+ return;
+ }
+ if (other.Message.Length != 0) {
+ Message = other.Message;
+ }
+ }
+
+ public void MergeFrom(pb::CodedInputStream input) {
+ uint tag;
+ while ((tag = input.ReadTag()) != 0) {
+ switch(tag) {
+ default:
+ input.SkipLastField();
+ break;
+ case 10: {
+ Message = input.ReadString();
+ break;
+ }
+ }
+ }
+ }
+
+ }
+
+ #endregion
+
+}
+
+#endregion Designer generated code
diff --git a/examples/csharp/helloworld/Greeter/HelloworldGrpc.cs b/examples/csharp/helloworld/Greeter/HelloworldGrpc.cs
new file mode 100644
index 0000000000..edfe4d2257
--- /dev/null
+++ b/examples/csharp/helloworld/Greeter/HelloworldGrpc.cs
@@ -0,0 +1,89 @@
+// Generated by the protocol buffer compiler. DO NOT EDIT!
+// source: helloworld.proto
+#region Designer generated code
+
+using System;
+using System.Threading;
+using System.Threading.Tasks;
+using Grpc.Core;
+
+namespace Helloworld {
+ public static class Greeter
+ {
+ static readonly string __ServiceName = "helloworld.Greeter";
+
+ static readonly Marshaller<global::Helloworld.HelloRequest> __Marshaller_HelloRequest = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Helloworld.HelloRequest.Parser.ParseFrom);
+ static readonly Marshaller<global::Helloworld.HelloReply> __Marshaller_HelloReply = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Helloworld.HelloReply.Parser.ParseFrom);
+
+ static readonly Method<global::Helloworld.HelloRequest, global::Helloworld.HelloReply> __Method_SayHello = new Method<global::Helloworld.HelloRequest, global::Helloworld.HelloReply>(
+ MethodType.Unary,
+ __ServiceName,
+ "SayHello",
+ __Marshaller_HelloRequest,
+ __Marshaller_HelloReply);
+
+ // service descriptor
+ public static global::Google.Protobuf.Reflection.ServiceDescriptor Descriptor
+ {
+ get { return global::Helloworld.Helloworld.Descriptor.Services[0]; }
+ }
+
+ // client interface
+ public interface IGreeterClient
+ {
+ global::Helloworld.HelloReply SayHello(global::Helloworld.HelloRequest request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken));
+ global::Helloworld.HelloReply SayHello(global::Helloworld.HelloRequest request, CallOptions options);
+ AsyncUnaryCall<global::Helloworld.HelloReply> SayHelloAsync(global::Helloworld.HelloRequest request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken));
+ AsyncUnaryCall<global::Helloworld.HelloReply> SayHelloAsync(global::Helloworld.HelloRequest request, CallOptions options);
+ }
+
+ // server-side interface
+ public interface IGreeter
+ {
+ Task<global::Helloworld.HelloReply> SayHello(global::Helloworld.HelloRequest request, ServerCallContext context);
+ }
+
+ // client stub
+ public class GreeterClient : ClientBase, IGreeterClient
+ {
+ public GreeterClient(Channel channel) : base(channel)
+ {
+ }
+ public global::Helloworld.HelloReply SayHello(global::Helloworld.HelloRequest request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ var call = CreateCall(__Method_SayHello, new CallOptions(headers, deadline, cancellationToken));
+ return Calls.BlockingUnaryCall(call, request);
+ }
+ public global::Helloworld.HelloReply SayHello(global::Helloworld.HelloRequest request, CallOptions options)
+ {
+ var call = CreateCall(__Method_SayHello, options);
+ return Calls.BlockingUnaryCall(call, request);
+ }
+ public AsyncUnaryCall<global::Helloworld.HelloReply> SayHelloAsync(global::Helloworld.HelloRequest request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ var call = CreateCall(__Method_SayHello, new CallOptions(headers, deadline, cancellationToken));
+ return Calls.AsyncUnaryCall(call, request);
+ }
+ public AsyncUnaryCall<global::Helloworld.HelloReply> SayHelloAsync(global::Helloworld.HelloRequest request, CallOptions options)
+ {
+ var call = CreateCall(__Method_SayHello, options);
+ return Calls.AsyncUnaryCall(call, request);
+ }
+ }
+
+ // creates service definition that can be registered with a server
+ public static ServerServiceDefinition BindService(IGreeter serviceImpl)
+ {
+ return ServerServiceDefinition.CreateBuilder(__ServiceName)
+ .AddMethod(__Method_SayHello, serviceImpl.SayHello).Build();
+ }
+
+ // creates a new client
+ public static GreeterClient NewClient(Channel channel)
+ {
+ return new GreeterClient(channel);
+ }
+
+ }
+}
+#endregion
diff --git a/examples/csharp/Greeter/Properties/AssemblyInfo.cs b/examples/csharp/helloworld/Greeter/Properties/AssemblyInfo.cs
index b9d0dc264d..b9d0dc264d 100644
--- a/examples/csharp/Greeter/Properties/AssemblyInfo.cs
+++ b/examples/csharp/helloworld/Greeter/Properties/AssemblyInfo.cs
diff --git a/examples/csharp/helloworld/Greeter/packages.config b/examples/csharp/helloworld/Greeter/packages.config
new file mode 100644
index 0000000000..1273624cbd
--- /dev/null
+++ b/examples/csharp/helloworld/Greeter/packages.config
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+ <package id="Google.Protobuf" version="3.0.0-alpha4" targetFramework="net45" />
+ <package id="Grpc" version="0.7.0" targetFramework="net45" />
+ <package id="Grpc.Core" version="0.7.0" targetFramework="net45" />
+ <package id="grpc.dependencies.openssl.redist" version="1.0.2.3" targetFramework="net45" />
+ <package id="grpc.dependencies.zlib.redist" version="1.2.8.9" targetFramework="net45" />
+ <package id="grpc.native.csharp_ext" version="0.11.0" targetFramework="net45" />
+ <package id="Ix-Async" version="1.2.3" targetFramework="net45" />
+</packages> \ No newline at end of file
diff --git a/examples/csharp/GreeterClient/.gitignore b/examples/csharp/helloworld/GreeterClient/.gitignore
index 1746e3269e..1746e3269e 100644
--- a/examples/csharp/GreeterClient/.gitignore
+++ b/examples/csharp/helloworld/GreeterClient/.gitignore
diff --git a/examples/csharp/GreeterClient/GreeterClient.csproj b/examples/csharp/helloworld/GreeterClient/GreeterClient.csproj
index 59b768af01..7874172bf2 100644
--- a/examples/csharp/GreeterClient/GreeterClient.csproj
+++ b/examples/csharp/helloworld/GreeterClient/GreeterClient.csproj
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.props" Condition="Exists('..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.props')" />
- <Import Project="..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.props" Condition="Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.props')" />
+ <Import Project="..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props" Condition="Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props')" />
+ <Import Project="..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props" Condition="Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props')" />
<Import Project="..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.props" Condition="Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -13,7 +13,7 @@
<RootNamespace>GreeterClient</RootNamespace>
<AssemblyName>GreeterClient</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
- <NuGetPackageImportStamp>985ca8be</NuGetPackageImportStamp>
+ <NuGetPackageImportStamp>c4057b0a</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@@ -34,21 +34,14 @@
<Externalconsole>true</Externalconsole>
</PropertyGroup>
<ItemGroup>
- <Reference Include="Google.ProtocolBuffers">
- <HintPath>..\packages\Google.ProtocolBuffers.2.4.1.555\lib\net40\Google.ProtocolBuffers.dll</HintPath>
+ <Reference Include="Google.Protobuf">
+ <HintPath>..\packages\Google.Protobuf.3.0.0-alpha4\lib\portable-net45+netcore45+wpa81+wp8\Google.Protobuf.dll</HintPath>
</Reference>
- <Reference Include="Google.ProtocolBuffers.Serialization">
- <HintPath>..\packages\Google.ProtocolBuffers.2.4.1.555\lib\net40\Google.ProtocolBuffers.Serialization.dll</HintPath>
- </Reference>
- <Reference Include="Grpc.Core, Version=0.6.5668.37363, Culture=neutral, processorArchitecture=MSIL">
+ <Reference Include="Grpc.Core, Version=0.7.0.0, Culture=neutral, PublicKeyToken=d754f35622e28bad, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\Grpc.Core.0.6.0\lib\net45\Grpc.Core.dll</HintPath>
+ <HintPath>..\packages\Grpc.Core.0.7.0\lib\net45\Grpc.Core.dll</HintPath>
</Reference>
<Reference Include="System" />
- <Reference Include="System.Collections.Immutable, Version=1.1.36.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\System.Collections.Immutable.1.1.36\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll</HintPath>
- </Reference>
<Reference Include="System.Interactive.Async">
<HintPath>..\packages\Ix-Async.1.2.3\lib\net45\System.Interactive.Async.dll</HintPath>
</Reference>
@@ -73,12 +66,12 @@
</PropertyGroup>
<Error Condition="!Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.props'))" />
<Error Condition="!Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets'))" />
- <Error Condition="!Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.props'))" />
- <Error Condition="!Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.targets'))" />
- <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.props'))" />
- <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.targets'))" />
+ <Error Condition="!Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props'))" />
+ <Error Condition="!Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets'))" />
+ <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props'))" />
+ <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets'))" />
</Target>
<Import Project="..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets" Condition="Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets')" />
- <Import Project="..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.targets" Condition="Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.targets')" />
- <Import Project="..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.targets" Condition="Exists('..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.targets')" />
+ <Import Project="..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets" Condition="Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets')" />
+ <Import Project="..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets" Condition="Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets')" />
</Project> \ No newline at end of file
diff --git a/examples/csharp/helloworld/GreeterClient/Program.cs b/examples/csharp/helloworld/GreeterClient/Program.cs
new file mode 100644
index 0000000000..279cee07e1
--- /dev/null
+++ b/examples/csharp/helloworld/GreeterClient/Program.cs
@@ -0,0 +1,24 @@
+using System;
+using Grpc.Core;
+using Helloworld;
+
+namespace GreeterClient
+{
+ class Program
+ {
+ public static void Main(string[] args)
+ {
+ Channel channel = new Channel("127.0.0.1:50051", Credentials.Insecure);
+
+ var client = Greeter.NewClient(channel);
+ String user = "you";
+
+ var reply = client.SayHello(new HelloRequest { Name = user });
+ Console.WriteLine("Greeting: " + reply.Message);
+
+ channel.ShutdownAsync().Wait();
+ Console.WriteLine("Press any key to exit...");
+ Console.ReadKey();
+ }
+ }
+}
diff --git a/examples/csharp/GreeterClient/Properties/AssemblyInfo.cs b/examples/csharp/helloworld/GreeterClient/Properties/AssemblyInfo.cs
index 1422e952d8..1422e952d8 100644
--- a/examples/csharp/GreeterClient/Properties/AssemblyInfo.cs
+++ b/examples/csharp/helloworld/GreeterClient/Properties/AssemblyInfo.cs
diff --git a/examples/csharp/helloworld/GreeterClient/packages.config b/examples/csharp/helloworld/GreeterClient/packages.config
new file mode 100644
index 0000000000..1273624cbd
--- /dev/null
+++ b/examples/csharp/helloworld/GreeterClient/packages.config
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+ <package id="Google.Protobuf" version="3.0.0-alpha4" targetFramework="net45" />
+ <package id="Grpc" version="0.7.0" targetFramework="net45" />
+ <package id="Grpc.Core" version="0.7.0" targetFramework="net45" />
+ <package id="grpc.dependencies.openssl.redist" version="1.0.2.3" targetFramework="net45" />
+ <package id="grpc.dependencies.zlib.redist" version="1.2.8.9" targetFramework="net45" />
+ <package id="grpc.native.csharp_ext" version="0.11.0" targetFramework="net45" />
+ <package id="Ix-Async" version="1.2.3" targetFramework="net45" />
+</packages> \ No newline at end of file
diff --git a/examples/csharp/GreeterServer/.gitignore b/examples/csharp/helloworld/GreeterServer/.gitignore
index 1746e3269e..1746e3269e 100644
--- a/examples/csharp/GreeterServer/.gitignore
+++ b/examples/csharp/helloworld/GreeterServer/.gitignore
diff --git a/examples/csharp/GreeterServer/GreeterServer.csproj b/examples/csharp/helloworld/GreeterServer/GreeterServer.csproj
index cd50d6cd52..d1db2f4773 100644
--- a/examples/csharp/GreeterServer/GreeterServer.csproj
+++ b/examples/csharp/helloworld/GreeterServer/GreeterServer.csproj
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.props" Condition="Exists('..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.props')" />
- <Import Project="..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.props" Condition="Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.props')" />
+ <Import Project="..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props" Condition="Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props')" />
+ <Import Project="..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props" Condition="Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props')" />
<Import Project="..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.props" Condition="Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -13,7 +13,7 @@
<RootNamespace>GreeterServer</RootNamespace>
<AssemblyName>GreeterServer</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
- <NuGetPackageImportStamp>a1eeb1d8</NuGetPackageImportStamp>
+ <NuGetPackageImportStamp>cc15afe5</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@@ -34,21 +34,14 @@
<Externalconsole>true</Externalconsole>
</PropertyGroup>
<ItemGroup>
- <Reference Include="Google.ProtocolBuffers">
- <HintPath>..\packages\Google.ProtocolBuffers.2.4.1.555\lib\net40\Google.ProtocolBuffers.dll</HintPath>
+ <Reference Include="Google.Protobuf">
+ <HintPath>..\packages\Google.Protobuf.3.0.0-alpha4\lib\portable-net45+netcore45+wpa81+wp8\Google.Protobuf.dll</HintPath>
</Reference>
- <Reference Include="Google.ProtocolBuffers.Serialization">
- <HintPath>..\packages\Google.ProtocolBuffers.2.4.1.555\lib\net40\Google.ProtocolBuffers.Serialization.dll</HintPath>
- </Reference>
- <Reference Include="Grpc.Core, Version=0.6.5668.37363, Culture=neutral, processorArchitecture=MSIL">
+ <Reference Include="Grpc.Core, Version=0.7.0.0, Culture=neutral, PublicKeyToken=d754f35622e28bad, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\Grpc.Core.0.6.0\lib\net45\Grpc.Core.dll</HintPath>
+ <HintPath>..\packages\Grpc.Core.0.7.0\lib\net45\Grpc.Core.dll</HintPath>
</Reference>
<Reference Include="System" />
- <Reference Include="System.Collections.Immutable, Version=1.1.36.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\System.Collections.Immutable.1.1.36\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll</HintPath>
- </Reference>
<Reference Include="System.Interactive.Async">
<HintPath>..\packages\Ix-Async.1.2.3\lib\net45\System.Interactive.Async.dll</HintPath>
</Reference>
@@ -73,12 +66,12 @@
</PropertyGroup>
<Error Condition="!Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.props'))" />
<Error Condition="!Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets'))" />
- <Error Condition="!Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.props'))" />
- <Error Condition="!Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.targets'))" />
- <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.props'))" />
- <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.targets'))" />
+ <Error Condition="!Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props'))" />
+ <Error Condition="!Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets'))" />
+ <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props'))" />
+ <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets'))" />
</Target>
<Import Project="..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets" Condition="Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets')" />
- <Import Project="..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.targets" Condition="Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.targets')" />
- <Import Project="..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.targets" Condition="Exists('..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.targets')" />
+ <Import Project="..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets" Condition="Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets')" />
+ <Import Project="..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets" Condition="Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets')" />
</Project> \ No newline at end of file
diff --git a/examples/csharp/helloworld/GreeterServer/Program.cs b/examples/csharp/helloworld/GreeterServer/Program.cs
new file mode 100644
index 0000000000..0214b359a9
--- /dev/null
+++ b/examples/csharp/helloworld/GreeterServer/Program.cs
@@ -0,0 +1,37 @@
+using System;
+using System.Threading.Tasks;
+using Grpc.Core;
+using Helloworld;
+
+namespace GreeterServer
+{
+ class GreeterImpl : Greeter.IGreeter
+ {
+ // Server side handler of the SayHello RPC
+ public Task<HelloReply> SayHello(HelloRequest request, ServerCallContext context)
+ {
+ return Task.FromResult(new HelloReply { Message = "Hello " + request.Name });
+ }
+ }
+
+ class Program
+ {
+ const int Port = 50051;
+
+ public static void Main(string[] args)
+ {
+ Server server = new Server
+ {
+ Services = { Greeter.BindService(new GreeterImpl()) },
+ Ports = { new ServerPort("localhost", Port, ServerCredentials.Insecure) }
+ };
+ server.Start();
+
+ Console.WriteLine("Greeter server listening on port " + Port);
+ Console.WriteLine("Press any key to stop the server...");
+ Console.ReadKey();
+
+ server.ShutdownAsync().Wait();
+ }
+ }
+}
diff --git a/examples/csharp/GreeterServer/Properties/AssemblyInfo.cs b/examples/csharp/helloworld/GreeterServer/Properties/AssemblyInfo.cs
index f8a8d521d8..f8a8d521d8 100644
--- a/examples/csharp/GreeterServer/Properties/AssemblyInfo.cs
+++ b/examples/csharp/helloworld/GreeterServer/Properties/AssemblyInfo.cs
diff --git a/examples/csharp/helloworld/GreeterServer/packages.config b/examples/csharp/helloworld/GreeterServer/packages.config
new file mode 100644
index 0000000000..1273624cbd
--- /dev/null
+++ b/examples/csharp/helloworld/GreeterServer/packages.config
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+ <package id="Google.Protobuf" version="3.0.0-alpha4" targetFramework="net45" />
+ <package id="Grpc" version="0.7.0" targetFramework="net45" />
+ <package id="Grpc.Core" version="0.7.0" targetFramework="net45" />
+ <package id="grpc.dependencies.openssl.redist" version="1.0.2.3" targetFramework="net45" />
+ <package id="grpc.dependencies.zlib.redist" version="1.2.8.9" targetFramework="net45" />
+ <package id="grpc.native.csharp_ext" version="0.11.0" targetFramework="net45" />
+ <package id="Ix-Async" version="1.2.3" targetFramework="net45" />
+</packages> \ No newline at end of file
diff --git a/examples/csharp/README.md b/examples/csharp/helloworld/README.md
index 3719080f4a..3719080f4a 100644
--- a/examples/csharp/README.md
+++ b/examples/csharp/helloworld/README.md
diff --git a/examples/csharp/helloworld/generate_protos.bat b/examples/csharp/helloworld/generate_protos.bat
new file mode 100644
index 0000000000..9a5a9d3ee3
--- /dev/null
+++ b/examples/csharp/helloworld/generate_protos.bat
@@ -0,0 +1,10 @@
+@rem Generate the C# code for .proto files
+
+setlocal
+
+@rem enter this directory
+cd /d %~dp0
+
+packages\Google.Protobuf.3.0.0-alpha4\tools\protoc.exe -I../../protos --csharp_out Greeter ../../protos/helloworld.proto --grpc_out Greeter --plugin=protoc-gen-grpc=packages\Grpc.Tools.0.7.0\tools\grpc_csharp_plugin.exe
+
+endlocal \ No newline at end of file
diff --git a/examples/csharp/route_guide/.nuget/packages.config b/examples/csharp/route_guide/.nuget/packages.config
index b14373069f..e2879c1893 100644
--- a/examples/csharp/route_guide/.nuget/packages.config
+++ b/examples/csharp/route_guide/.nuget/packages.config
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
- <package id="Grpc.Tools" version="0.6.0" />
+ <package id="Grpc.Tools" version="0.7.0" />
</packages> \ No newline at end of file
diff --git a/examples/csharp/route_guide/README.md b/examples/csharp/route_guide/README.md
index ec9a0c048e..155877e62e 100644
--- a/examples/csharp/route_guide/README.md
+++ b/examples/csharp/route_guide/README.md
@@ -93,16 +93,16 @@ message Point {
Next we need to generate the gRPC client and server interfaces from our .proto service definition. We do this using the protocol buffer compiler `protoc` with a special gRPC C# plugin.
If you want to run this yourself, make sure you've installed protoc and gRPC C# plugin. The instructions vary based on your OS:
-- For Windows, the `Grpc.Tools` NuGet package contains the binaries you will need to generate the code.
+- For Windows, the `Grpc.Tools` and `Google.Protobuf` NuGet packages contain the binaries you will need to generate the code.
- For Linux, make sure you've [installed gRPC C Core using Linuxbrew](https://github.com/grpc/grpc/tree/master/src/csharp#usage-linux-mono)
- For MacOS, make sure you've [installed gRPC C Core using Homebrew](https://github.com/grpc/grpc/tree/master/src/csharp#usage-macos-mono)
Once that's done, the following command can be used to generate the C# code.
-To generate the code on Windows, we use `protoc.exe` and `grpc_csharp_plugin.exe` binaries that are shipped with the `Grpc.Tools` NuGet package under the `tools` directory.
+To generate the code on Windows, we use `protoc.exe` from the `Google.Protobuf` NuGet package and `grpc_csharp_plugin.exe` from the `Grpc.Tools` NuGet package (both under the `tools` directory).
Normally you would need to add the `Grpc.Tools` package to the solution yourself, but in this tutorial it has been already done for you. Following command should be run from the `csharp/route_guide` directory:
```
-> packages\Grpc.Tools.0.5.1\tools\protoc -I RouteGuide/protos --csharp_out=RouteGuide --grpc_out=RouteGuide --plugin=protoc-gen-grpc=packages\Grpc.Tools.0.5.1\tools\grpc_csharp_plugin.exe RouteGuide/protos/route_guide.proto
+> packages\Google.Protobuf.3.0.0-alpha4\tools\protoc -I RouteGuide/protos --csharp_out=RouteGuide --grpc_out=RouteGuide --plugin=protoc-gen-grpc=packages\Grpc.Tools.0.7.0\tools\grpc_csharp_plugin.exe RouteGuide/protos/route_guide.proto
```
On Linux/MacOS, we rely on `protoc` and `grpc_csharp_plugin` being installed by Linuxbrew/Homebrew. Run this command from the route_guide directory:
@@ -143,7 +143,7 @@ public class RouteGuideImpl : RouteGuide.IRouteGuide
`RouteGuideImpl` implements all our service methods. Let's look at the simplest type first, `GetFeature`, which just gets a `Point` from the client and returns the corresponding feature information from its database in a `Feature`.
```csharp
- public Task<Feature> GetFeature(Grpc.Core.ServerCallContext context, Point request)
+ public Task<Feature> GetFeature(Point request, Grpc.Core.ServerCallContext context)
{
return Task.FromResult(CheckFeature(request));
}
@@ -159,27 +159,14 @@ Now let's look at something a bit more complicated - a streaming RPC. `ListFeatu
```csharp
// in RouteGuideImpl
- public async Task ListFeatures(Grpc.Core.ServerCallContext context, Rectangle request,
- Grpc.Core.IServerStreamWriter<Feature> responseStream)
+ public async Task ListFeatures(Rectangle request,
+ Grpc.Core.IServerStreamWriter<Feature> responseStream,
+ Grpc.Core.ServerCallContext context)
{
- int left = Math.Min(request.Lo.Longitude, request.Hi.Longitude);
- int right = Math.Max(request.Lo.Longitude, request.Hi.Longitude);
- int top = Math.Max(request.Lo.Latitude, request.Hi.Latitude);
- int bottom = Math.Min(request.Lo.Latitude, request.Hi.Latitude);
-
- foreach (var feature in features)
+ var responses = features.FindAll( (feature) => feature.Exists() && request.Contains(feature.Location) );
+ foreach (var response in responses)
{
- if (!RouteGuideUtil.Exists(feature))
- {
- continue;
- }
-
- int lat = feature.Location.Latitude;
- int lon = feature.Location.Longitude;
- if (lon >= left && lon <= right && lat >= bottom && lat <= top)
- {
- await responseStream.WriteAsync(feature);
- }
+ await responseStream.WriteAsync(response);
}
}
```
@@ -191,8 +178,8 @@ As you can see, here the request object is a `Rectangle` in which our client wan
Similarly, the client-side streaming method `RecordRoute` uses an [IAsyncEnumerator](https://github.com/Reactive-Extensions/Rx.NET/blob/master/Ix.NET/Source/System.Interactive.Async/IAsyncEnumerator.cs), to read the stream of requests using the async method `MoveNext` and the `Current` property.
```csharp
- public async Task<RouteSummary> RecordRoute(Grpc.Core.ServerCallContext context,
- Grpc.Core.IAsyncStreamReader<Point> requestStream)
+ public async Task<RouteSummary> RecordRoute(Grpc.Core.IAsyncStreamReader<Point> requestStream,
+ Grpc.Core.ServerCallContext context)
{
int pointCount = 0;
int featureCount = 0;
@@ -205,21 +192,26 @@ Similarly, the client-side streaming method `RecordRoute` uses an [IAsyncEnumera
{
var point = requestStream.Current;
pointCount++;
- if (RouteGuideUtil.Exists(CheckFeature(point)))
+ if (CheckFeature(point).Exists())
{
featureCount++;
}
if (previous != null)
{
- distance += (int) CalcDistance(previous, point);
+ distance += (int) previous.GetDistance(point);
}
previous = point;
}
stopwatch.Stop();
- return RouteSummary.CreateBuilder().SetPointCount(pointCount)
- .SetFeatureCount(featureCount).SetDistance(distance)
- .SetElapsedTime((int) (stopwatch.ElapsedMilliseconds / 1000)).Build();
+
+ return new RouteSummary
+ {
+ PointCount = pointCount,
+ FeatureCount = featureCount,
+ Distance = distance,
+ ElapsedTime = (int)(stopwatch.ElapsedMilliseconds / 1000)
+ };
}
```
@@ -228,28 +220,17 @@ Similarly, the client-side streaming method `RecordRoute` uses an [IAsyncEnumera
Finally, let's look at our bidirectional streaming RPC `RouteChat`.
```csharp
- public async Task RouteChat(Grpc.Core.ServerCallContext context,
- Grpc.Core.IAsyncStreamReader<RouteNote> requestStream, Grpc.Core.IServerStreamWriter<RouteNote> responseStream)
+ public async Task RouteChat(Grpc.Core.IAsyncStreamReader<RouteNote> requestStream,
+ Grpc.Core.IServerStreamWriter<RouteNote> responseStream,
+ Grpc.Core.ServerCallContext context,)
{
while (await requestStream.MoveNext())
- {
+ {
var note = requestStream.Current;
- List<RouteNote> notes = GetOrCreateNotes(note.Location);
-
- List<RouteNote> prevNotes;
- lock (notes)
- {
- prevNotes = new List<RouteNote>(notes);
- }
-
+ List<RouteNote> prevNotes = AddNoteForLocation(note.Location, note);
foreach (var prevNote in prevNotes)
{
await responseStream.WriteAsync(prevNote);
- }
-
- lock (notes)
- {
- notes.Add(note);
}
}
}
@@ -263,11 +244,12 @@ Once we've implemented all our methods, we also need to start up a gRPC server s
```csharp
var features = RouteGuideUtil.ParseFeatures(RouteGuideUtil.DefaultFeaturesFile);
-GrpcEnvironment.Initialize();
-Server server = new Server();
-server.AddServiceDefinition(RouteGuide.BindService(new RouteGuideImpl(features)));
-int port = server.AddListeningPort("localhost", 50052);
+Server server = new Server
+{
+ Services = { RouteGuide.BindService(new RouteGuideImpl(features)) },
+ Ports = { new ServerPort("localhost", Port, ServerCredentials.Insecure) }
+};
server.Start();
Console.WriteLine("RouteGuide server listening on port " + port);
@@ -275,14 +257,13 @@ Console.WriteLine("Press any key to stop the server...");
Console.ReadKey();
server.ShutdownAsync().Wait();
-GrpcEnvironment.Shutdown();
```
As you can see, we build and start our server using `Grpc.Core.Server` class. To do this, we:
1. Create an instance of `Grpc.Core.Server`.
1. Create an instance of our service implementation class `RouteGuideImpl`.
-3. Register our service implementation with the server using the `AddServiceDefinition` method and the generated method `RouteGuide.BindService`.
-2. Specify the address and port we want to use to listen for client requests using the `AddListeningPort` method.
+3. Register our service implementation by adding its service definition to `Services` collection (We obtain the service definition from the generated `RouteGuide.BindService` method).
+2. Specify the address and port we want to use to listen for client requests. This is done by adding `ServerPort` to `Ports` collection.
4. Call `Start` on the server instance to start an RPC server for our service.
<a name="client"></a>
@@ -294,19 +275,15 @@ In this section, we'll look at creating a C# client for our `RouteGuide` service
To call service methods, we first need to create a *stub*.
-First, we need to create a gRPC client channel that will connect to gRPC server. Then, we use the `RouteGuide.NewStub` method of the `RouteGuide` class generated from our .proto.
+First, we need to create a gRPC client channel that will connect to gRPC server. Then, we use the `RouteGuide.NewClient` method of the `RouteGuide` class generated from our .proto.
```csharp
-GrpcEnvironment.Initialize();
+Channel channel = new Channel("127.0.0.1:50052", Credentials.Insecure)
+var client = new RouteGuideClient(RouteGuide.NewClient(channel));
-using (Channel channel = new Channel("127.0.0.1:50052"))
-{
- var client = RouteGuide.NewStub(channel);
-
- // YOUR CODE GOES HERE
-}
+// YOUR CODE GOES HERE
-GrpcEnvironment.Shutdown();
+channel.ShutdownAsync().Wait();
```
### Calling service methods
@@ -319,7 +296,7 @@ gRPC C# also provides a synchronous method stub, but only for simple (single req
Calling the simple RPC `GetFeature` in a synchronous way is nearly as straightforward as calling a local method.
```csharp
-Point request = Point.CreateBuilder().SetLatitude(409146138).SetLongitude(-746188906).Build();
+Point request = new Point { Latitude = 409146138, Longitude = -746188906 };
Feature feature = client.GetFeature(request);
```
@@ -327,7 +304,7 @@ As you can see, we create and populate a request protocol buffer object (in our
Alternatively, if you are in async context, you can call an asynchronous version of the method (and use `await` keyword to await the result):
```csharp
-Point request = Point.CreateBuilder().SetLatitude(409146138).SetLongitude(-746188906).Build();
+Point request = new Point { Latitude = 409146138, Longitude = -746188906 };
Feature feature = await client.GetFeatureAsync(request);
```
@@ -349,17 +326,17 @@ using (var call = client.ListFeatures(request))
```
The client-side streaming method `RecordRoute` is similar, except we use the property `RequestStream` to write the requests one by one using `WriteAsync` and eventually signal that no more request will be send using `CompleteAsync`. The method result can be obtained through the property
-`Result`.
+`ResponseAsync`.
```csharp
using (var call = client.RecordRoute())
{
foreach (var point in points)
- {
+ {
await call.RequestStream.WriteAsync(point);
}
await call.RequestStream.CompleteAsync();
- RouteSummary summary = await call.Result;
+ RouteSummary summary = await call.ResponseAsync;
}
```
@@ -374,7 +351,7 @@ Finally, let's look at our bidirectional streaming RPC `RouteChat`. In this case
{
var note = call.ResponseStream.Current;
Console.WriteLine("Received " + note);
- }
+ }
});
foreach (RouteNote request in requests)
@@ -382,7 +359,7 @@ Finally, let's look at our bidirectional streaming RPC `RouteChat`. In this case
await call.RequestStream.WriteAsync(request);
}
await call.RequestStream.CompleteAsync();
- await responseReaderTask;
+ await responseReaderTask;
}
```
diff --git a/examples/csharp/route_guide/RouteGuide/RouteGuide.cs b/examples/csharp/route_guide/RouteGuide/RouteGuide.cs
index 80508bcd3f..9bc6f307d2 100644
--- a/examples/csharp/route_guide/RouteGuide/RouteGuide.cs
+++ b/examples/csharp/route_guide/RouteGuide/RouteGuide.cs
@@ -3,38 +3,22 @@
#pragma warning disable 1591, 0612, 3021
#region Designer generated code
-using pb = global::Google.ProtocolBuffers;
-using pbc = global::Google.ProtocolBuffers.Collections;
-using pbd = global::Google.ProtocolBuffers.Descriptors;
+using pb = global::Google.Protobuf;
+using pbc = global::Google.Protobuf.Collections;
+using pbr = global::Google.Protobuf.Reflection;
using scg = global::System.Collections.Generic;
-namespace examples {
+namespace Examples {
namespace Proto {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
public static partial class RouteGuide {
- #region Extension registration
- public static void RegisterAllExtensions(pb::ExtensionRegistry registry) {
- }
- #endregion
- #region Static variables
- internal static pbd::MessageDescriptor internal__static_examples_Point__Descriptor;
- internal static pb::FieldAccess.FieldAccessorTable<global::examples.Point, global::examples.Point.Builder> internal__static_examples_Point__FieldAccessorTable;
- internal static pbd::MessageDescriptor internal__static_examples_Rectangle__Descriptor;
- internal static pb::FieldAccess.FieldAccessorTable<global::examples.Rectangle, global::examples.Rectangle.Builder> internal__static_examples_Rectangle__FieldAccessorTable;
- internal static pbd::MessageDescriptor internal__static_examples_Feature__Descriptor;
- internal static pb::FieldAccess.FieldAccessorTable<global::examples.Feature, global::examples.Feature.Builder> internal__static_examples_Feature__FieldAccessorTable;
- internal static pbd::MessageDescriptor internal__static_examples_RouteNote__Descriptor;
- internal static pb::FieldAccess.FieldAccessorTable<global::examples.RouteNote, global::examples.RouteNote.Builder> internal__static_examples_RouteNote__FieldAccessorTable;
- internal static pbd::MessageDescriptor internal__static_examples_RouteSummary__Descriptor;
- internal static pb::FieldAccess.FieldAccessorTable<global::examples.RouteSummary, global::examples.RouteSummary.Builder> internal__static_examples_RouteSummary__FieldAccessorTable;
- #endregion
#region Descriptor
- public static pbd::FileDescriptor Descriptor {
+ public static pbr::FileDescriptor Descriptor {
get { return descriptor; }
}
- private static pbd::FileDescriptor descriptor;
+ private static pbr::FileDescriptor descriptor;
static RouteGuide() {
byte[] descriptorData = global::System.Convert.FromBase64String(
@@ -52,36 +36,17 @@ namespace examples {
"dXJlcxITLmV4YW1wbGVzLlJlY3RhbmdsZRoRLmV4YW1wbGVzLkZlYXR1cmUi",
"ADABEjoKC1JlY29yZFJvdXRlEg8uZXhhbXBsZXMuUG9pbnQaFi5leGFtcGxl",
"cy5Sb3V0ZVN1bW1hcnkiACgBEjsKCVJvdXRlQ2hhdBITLmV4YW1wbGVzLlJv",
- "dXRlTm90ZRoTLmV4YW1wbGVzLlJvdXRlTm90ZSIAKAEwAQ=="));
- pbd::FileDescriptor.InternalDescriptorAssigner assigner = delegate(pbd::FileDescriptor root) {
- descriptor = root;
- internal__static_examples_Point__Descriptor = Descriptor.MessageTypes[0];
- internal__static_examples_Point__FieldAccessorTable =
- new pb::FieldAccess.FieldAccessorTable<global::examples.Point, global::examples.Point.Builder>(internal__static_examples_Point__Descriptor,
- new string[] { "Latitude", "Longitude", });
- internal__static_examples_Rectangle__Descriptor = Descriptor.MessageTypes[1];
- internal__static_examples_Rectangle__FieldAccessorTable =
- new pb::FieldAccess.FieldAccessorTable<global::examples.Rectangle, global::examples.Rectangle.Builder>(internal__static_examples_Rectangle__Descriptor,
- new string[] { "Lo", "Hi", });
- internal__static_examples_Feature__Descriptor = Descriptor.MessageTypes[2];
- internal__static_examples_Feature__FieldAccessorTable =
- new pb::FieldAccess.FieldAccessorTable<global::examples.Feature, global::examples.Feature.Builder>(internal__static_examples_Feature__Descriptor,
- new string[] { "Name", "Location", });
- internal__static_examples_RouteNote__Descriptor = Descriptor.MessageTypes[3];
- internal__static_examples_RouteNote__FieldAccessorTable =
- new pb::FieldAccess.FieldAccessorTable<global::examples.RouteNote, global::examples.RouteNote.Builder>(internal__static_examples_RouteNote__Descriptor,
- new string[] { "Location", "Message", });
- internal__static_examples_RouteSummary__Descriptor = Descriptor.MessageTypes[4];
- internal__static_examples_RouteSummary__FieldAccessorTable =
- new pb::FieldAccess.FieldAccessorTable<global::examples.RouteSummary, global::examples.RouteSummary.Builder>(internal__static_examples_RouteSummary__Descriptor,
- new string[] { "PointCount", "FeatureCount", "Distance", "ElapsedTime", });
- pb::ExtensionRegistry registry = pb::ExtensionRegistry.CreateInstance();
- RegisterAllExtensions(registry);
- return registry;
- };
- pbd::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData,
- new pbd::FileDescriptor[] {
- }, assigner);
+ "dXRlTm90ZRoTLmV4YW1wbGVzLlJvdXRlTm90ZSIAKAEwAUIPCgdleC5ncnBj",
+ "ogIDUlRHYgZwcm90bzM="));
+ descriptor = pbr::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData,
+ new pbr::FileDescriptor[] { },
+ new pbr::GeneratedCodeInfo(null, new pbr::GeneratedCodeInfo[] {
+ new pbr::GeneratedCodeInfo(typeof(global::Examples.Point), new[]{ "Latitude", "Longitude" }, null, null, null),
+ new pbr::GeneratedCodeInfo(typeof(global::Examples.Rectangle), new[]{ "Lo", "Hi" }, null, null, null),
+ new pbr::GeneratedCodeInfo(typeof(global::Examples.Feature), new[]{ "Name", "Location" }, null, null, null),
+ new pbr::GeneratedCodeInfo(typeof(global::Examples.RouteNote), new[]{ "Location", "Message" }, null, null, null),
+ new pbr::GeneratedCodeInfo(typeof(global::Examples.RouteSummary), new[]{ "PointCount", "FeatureCount", "Distance", "ElapsedTime" }, null, null, null)
+ }));
}
#endregion
@@ -89,1781 +54,719 @@ namespace examples {
}
#region Messages
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- public sealed partial class Point : pb::GeneratedMessage<Point, Point.Builder> {
- private Point() { }
- private static readonly Point defaultInstance = new Point().MakeReadOnly();
- private static readonly string[] _pointFieldNames = new string[] { "latitude", "longitude" };
- private static readonly uint[] _pointFieldTags = new uint[] { 8, 16 };
- public static Point DefaultInstance {
- get { return defaultInstance; }
+ public sealed partial class Point : pb::IMessage<Point> {
+ private static readonly pb::MessageParser<Point> _parser = new pb::MessageParser<Point>(() => new Point());
+ public static pb::MessageParser<Point> Parser { get { return _parser; } }
+
+ public static pbr::MessageDescriptor Descriptor {
+ get { return global::Examples.Proto.RouteGuide.Descriptor.MessageTypes[0]; }
}
- public override Point DefaultInstanceForType {
- get { return DefaultInstance; }
+ pbr::MessageDescriptor pb::IMessage.Descriptor {
+ get { return Descriptor; }
}
- protected override Point ThisMessage {
- get { return this; }
+ public Point() {
+ OnConstruction();
}
- public static pbd::MessageDescriptor Descriptor {
- get { return global::examples.Proto.RouteGuide.internal__static_examples_Point__Descriptor; }
+ partial void OnConstruction();
+
+ public Point(Point other) : this() {
+ latitude_ = other.latitude_;
+ longitude_ = other.longitude_;
}
- protected override pb::FieldAccess.FieldAccessorTable<Point, Point.Builder> InternalFieldAccessors {
- get { return global::examples.Proto.RouteGuide.internal__static_examples_Point__FieldAccessorTable; }
+ public Point Clone() {
+ return new Point(this);
}
public const int LatitudeFieldNumber = 1;
- private bool hasLatitude;
private int latitude_;
- public bool HasLatitude {
- get { return hasLatitude; }
- }
public int Latitude {
get { return latitude_; }
+ set {
+ latitude_ = value;
+ }
}
public const int LongitudeFieldNumber = 2;
- private bool hasLongitude;
private int longitude_;
- public bool HasLongitude {
- get { return hasLongitude; }
- }
public int Longitude {
get { return longitude_; }
- }
-
- public override bool IsInitialized {
- get {
- return true;
+ set {
+ longitude_ = value;
}
}
- public override void WriteTo(pb::ICodedOutputStream output) {
- CalcSerializedSize();
- string[] field_names = _pointFieldNames;
- if (hasLatitude) {
- output.WriteInt32(1, field_names[0], Latitude);
- }
- if (hasLongitude) {
- output.WriteInt32(2, field_names[1], Longitude);
- }
- UnknownFields.WriteTo(output);
- }
-
- private int memoizedSerializedSize = -1;
- public override int SerializedSize {
- get {
- int size = memoizedSerializedSize;
- if (size != -1) return size;
- return CalcSerializedSize();
- }
+ public override bool Equals(object other) {
+ return Equals(other as Point);
}
- private int CalcSerializedSize() {
- int size = memoizedSerializedSize;
- if (size != -1) return size;
-
- size = 0;
- if (hasLatitude) {
- size += pb::CodedOutputStream.ComputeInt32Size(1, Latitude);
+ public bool Equals(Point other) {
+ if (ReferenceEquals(other, null)) {
+ return false;
}
- if (hasLongitude) {
- size += pb::CodedOutputStream.ComputeInt32Size(2, Longitude);
+ if (ReferenceEquals(other, this)) {
+ return true;
}
- size += UnknownFields.SerializedSize;
- memoizedSerializedSize = size;
- return size;
- }
- public static Point ParseFrom(pb::ByteString data) {
- return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed();
- }
- public static Point ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) {
- return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed();
- }
- public static Point ParseFrom(byte[] data) {
- return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed();
- }
- public static Point ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) {
- return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed();
- }
- public static Point ParseFrom(global::System.IO.Stream input) {
- return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed();
- }
- public static Point ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) {
- return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
- }
- public static Point ParseDelimitedFrom(global::System.IO.Stream input) {
- return CreateBuilder().MergeDelimitedFrom(input).BuildParsed();
- }
- public static Point ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) {
- return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed();
- }
- public static Point ParseFrom(pb::ICodedInputStream input) {
- return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed();
- }
- public static Point ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
- return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
- }
- private Point MakeReadOnly() {
- return this;
+ if (Latitude != other.Latitude) return false;
+ if (Longitude != other.Longitude) return false;
+ return true;
}
- public static Builder CreateBuilder() { return new Builder(); }
- public override Builder ToBuilder() { return CreateBuilder(this); }
- public override Builder CreateBuilderForType() { return new Builder(); }
- public static Builder CreateBuilder(Point prototype) {
- return new Builder(prototype);
+ public override int GetHashCode() {
+ int hash = 1;
+ if (Latitude != 0) hash ^= Latitude.GetHashCode();
+ if (Longitude != 0) hash ^= Longitude.GetHashCode();
+ return hash;
}
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- public sealed partial class Builder : pb::GeneratedBuilder<Point, Builder> {
- protected override Builder ThisBuilder {
- get { return this; }
- }
- public Builder() {
- result = DefaultInstance;
- resultIsReadOnly = true;
- }
- internal Builder(Point cloneFrom) {
- result = cloneFrom;
- resultIsReadOnly = true;
- }
-
- private bool resultIsReadOnly;
- private Point result;
+ public override string ToString() {
+ return pb::JsonFormatter.Default.Format(this);
+ }
- private Point PrepareBuilder() {
- if (resultIsReadOnly) {
- Point original = result;
- result = new Point();
- resultIsReadOnly = false;
- MergeFrom(original);
- }
- return result;
+ public void WriteTo(pb::CodedOutputStream output) {
+ if (Latitude != 0) {
+ output.WriteRawTag(8);
+ output.WriteInt32(Latitude);
}
-
- public override bool IsInitialized {
- get { return result.IsInitialized; }
- }
-
- protected override Point MessageBeingBuilt {
- get { return PrepareBuilder(); }
+ if (Longitude != 0) {
+ output.WriteRawTag(16);
+ output.WriteInt32(Longitude);
}
+ }
- public override Builder Clear() {
- result = DefaultInstance;
- resultIsReadOnly = true;
- return this;
+ public int CalculateSize() {
+ int size = 0;
+ if (Latitude != 0) {
+ size += 1 + pb::CodedOutputStream.ComputeInt32Size(Latitude);
}
-
- public override Builder Clone() {
- if (resultIsReadOnly) {
- return new Builder(result);
- } else {
- return new Builder().MergeFrom(result);
- }
- }
-
- public override pbd::MessageDescriptor DescriptorForType {
- get { return global::examples.Point.Descriptor; }
+ if (Longitude != 0) {
+ size += 1 + pb::CodedOutputStream.ComputeInt32Size(Longitude);
}
+ return size;
+ }
- public override Point DefaultInstanceForType {
- get { return global::examples.Point.DefaultInstance; }
+ public void MergeFrom(Point other) {
+ if (other == null) {
+ return;
}
-
- public override Point BuildPartial() {
- if (resultIsReadOnly) {
- return result;
- }
- resultIsReadOnly = true;
- return result.MakeReadOnly();
+ if (other.Latitude != 0) {
+ Latitude = other.Latitude;
}
-
- public override Builder MergeFrom(pb::IMessage other) {
- if (other is Point) {
- return MergeFrom((Point) other);
- } else {
- base.MergeFrom(other);
- return this;
- }
+ if (other.Longitude != 0) {
+ Longitude = other.Longitude;
}
+ }
- public override Builder MergeFrom(Point other) {
- if (other == global::examples.Point.DefaultInstance) return this;
- PrepareBuilder();
- if (other.HasLatitude) {
- Latitude = other.Latitude;
- }
- if (other.HasLongitude) {
- Longitude = other.Longitude;
- }
- this.MergeUnknownFields(other.UnknownFields);
- return this;
- }
-
- public override Builder MergeFrom(pb::ICodedInputStream input) {
- return MergeFrom(input, pb::ExtensionRegistry.Empty);
- }
-
- public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
- PrepareBuilder();
- pb::UnknownFieldSet.Builder unknownFields = null;
- uint tag;
- string field_name;
- while (input.ReadTag(out tag, out field_name)) {
- if(tag == 0 && field_name != null) {
- int field_ordinal = global::System.Array.BinarySearch(_pointFieldNames, field_name, global::System.StringComparer.Ordinal);
- if(field_ordinal >= 0)
- tag = _pointFieldTags[field_ordinal];
- else {
- if (unknownFields == null) {
- unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
- }
- ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
- continue;
- }
+ public void MergeFrom(pb::CodedInputStream input) {
+ uint tag;
+ while ((tag = input.ReadTag()) != 0) {
+ switch(tag) {
+ default:
+ input.SkipLastField();
+ break;
+ case 8: {
+ Latitude = input.ReadInt32();
+ break;
}
- switch (tag) {
- case 0: {
- throw pb::InvalidProtocolBufferException.InvalidTag();
- }
- default: {
- if (pb::WireFormat.IsEndGroupTag(tag)) {
- if (unknownFields != null) {
- this.UnknownFields = unknownFields.Build();
- }
- return this;
- }
- if (unknownFields == null) {
- unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
- }
- ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
- break;
- }
- case 8: {
- result.hasLatitude = input.ReadInt32(ref result.latitude_);
- break;
- }
- case 16: {
- result.hasLongitude = input.ReadInt32(ref result.longitude_);
- break;
- }
+ case 16: {
+ Longitude = input.ReadInt32();
+ break;
}
}
-
- if (unknownFields != null) {
- this.UnknownFields = unknownFields.Build();
- }
- return this;
- }
-
-
- public bool HasLatitude {
- get { return result.hasLatitude; }
- }
- public int Latitude {
- get { return result.Latitude; }
- set { SetLatitude(value); }
- }
- public Builder SetLatitude(int value) {
- PrepareBuilder();
- result.hasLatitude = true;
- result.latitude_ = value;
- return this;
- }
- public Builder ClearLatitude() {
- PrepareBuilder();
- result.hasLatitude = false;
- result.latitude_ = 0;
- return this;
- }
-
- public bool HasLongitude {
- get { return result.hasLongitude; }
- }
- public int Longitude {
- get { return result.Longitude; }
- set { SetLongitude(value); }
- }
- public Builder SetLongitude(int value) {
- PrepareBuilder();
- result.hasLongitude = true;
- result.longitude_ = value;
- return this;
- }
- public Builder ClearLongitude() {
- PrepareBuilder();
- result.hasLongitude = false;
- result.longitude_ = 0;
- return this;
}
}
- static Point() {
- object.ReferenceEquals(global::examples.Proto.RouteGuide.Descriptor, null);
- }
+
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- public sealed partial class Rectangle : pb::GeneratedMessage<Rectangle, Rectangle.Builder> {
- private Rectangle() { }
- private static readonly Rectangle defaultInstance = new Rectangle().MakeReadOnly();
- private static readonly string[] _rectangleFieldNames = new string[] { "hi", "lo" };
- private static readonly uint[] _rectangleFieldTags = new uint[] { 18, 10 };
- public static Rectangle DefaultInstance {
- get { return defaultInstance; }
- }
+ public sealed partial class Rectangle : pb::IMessage<Rectangle> {
+ private static readonly pb::MessageParser<Rectangle> _parser = new pb::MessageParser<Rectangle>(() => new Rectangle());
+ public static pb::MessageParser<Rectangle> Parser { get { return _parser; } }
- public override Rectangle DefaultInstanceForType {
- get { return DefaultInstance; }
+ public static pbr::MessageDescriptor Descriptor {
+ get { return global::Examples.Proto.RouteGuide.Descriptor.MessageTypes[1]; }
}
- protected override Rectangle ThisMessage {
- get { return this; }
+ pbr::MessageDescriptor pb::IMessage.Descriptor {
+ get { return Descriptor; }
}
- public static pbd::MessageDescriptor Descriptor {
- get { return global::examples.Proto.RouteGuide.internal__static_examples_Rectangle__Descriptor; }
+ public Rectangle() {
+ OnConstruction();
}
- protected override pb::FieldAccess.FieldAccessorTable<Rectangle, Rectangle.Builder> InternalFieldAccessors {
- get { return global::examples.Proto.RouteGuide.internal__static_examples_Rectangle__FieldAccessorTable; }
- }
+ partial void OnConstruction();
- public const int LoFieldNumber = 1;
- private bool hasLo;
- private global::examples.Point lo_;
- public bool HasLo {
- get { return hasLo; }
- }
- public global::examples.Point Lo {
- get { return lo_ ?? global::examples.Point.DefaultInstance; }
+ public Rectangle(Rectangle other) : this() {
+ Lo = other.lo_ != null ? other.Lo.Clone() : null;
+ Hi = other.hi_ != null ? other.Hi.Clone() : null;
}
- public const int HiFieldNumber = 2;
- private bool hasHi;
- private global::examples.Point hi_;
- public bool HasHi {
- get { return hasHi; }
- }
- public global::examples.Point Hi {
- get { return hi_ ?? global::examples.Point.DefaultInstance; }
+ public Rectangle Clone() {
+ return new Rectangle(this);
}
- public override bool IsInitialized {
- get {
- return true;
+ public const int LoFieldNumber = 1;
+ private global::Examples.Point lo_;
+ public global::Examples.Point Lo {
+ get { return lo_; }
+ set {
+ lo_ = value;
}
}
- public override void WriteTo(pb::ICodedOutputStream output) {
- CalcSerializedSize();
- string[] field_names = _rectangleFieldNames;
- if (hasLo) {
- output.WriteMessage(1, field_names[1], Lo);
- }
- if (hasHi) {
- output.WriteMessage(2, field_names[0], Hi);
+ public const int HiFieldNumber = 2;
+ private global::Examples.Point hi_;
+ public global::Examples.Point Hi {
+ get { return hi_; }
+ set {
+ hi_ = value;
}
- UnknownFields.WriteTo(output);
}
- private int memoizedSerializedSize = -1;
- public override int SerializedSize {
- get {
- int size = memoizedSerializedSize;
- if (size != -1) return size;
- return CalcSerializedSize();
- }
+ public override bool Equals(object other) {
+ return Equals(other as Rectangle);
}
- private int CalcSerializedSize() {
- int size = memoizedSerializedSize;
- if (size != -1) return size;
-
- size = 0;
- if (hasLo) {
- size += pb::CodedOutputStream.ComputeMessageSize(1, Lo);
+ public bool Equals(Rectangle other) {
+ if (ReferenceEquals(other, null)) {
+ return false;
}
- if (hasHi) {
- size += pb::CodedOutputStream.ComputeMessageSize(2, Hi);
+ if (ReferenceEquals(other, this)) {
+ return true;
}
- size += UnknownFields.SerializedSize;
- memoizedSerializedSize = size;
- return size;
- }
- public static Rectangle ParseFrom(pb::ByteString data) {
- return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed();
- }
- public static Rectangle ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) {
- return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed();
- }
- public static Rectangle ParseFrom(byte[] data) {
- return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed();
- }
- public static Rectangle ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) {
- return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed();
- }
- public static Rectangle ParseFrom(global::System.IO.Stream input) {
- return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed();
- }
- public static Rectangle ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) {
- return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
- }
- public static Rectangle ParseDelimitedFrom(global::System.IO.Stream input) {
- return CreateBuilder().MergeDelimitedFrom(input).BuildParsed();
- }
- public static Rectangle ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) {
- return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed();
- }
- public static Rectangle ParseFrom(pb::ICodedInputStream input) {
- return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed();
- }
- public static Rectangle ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
- return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
- }
- private Rectangle MakeReadOnly() {
- return this;
+ if (!object.Equals(Lo, other.Lo)) return false;
+ if (!object.Equals(Hi, other.Hi)) return false;
+ return true;
}
- public static Builder CreateBuilder() { return new Builder(); }
- public override Builder ToBuilder() { return CreateBuilder(this); }
- public override Builder CreateBuilderForType() { return new Builder(); }
- public static Builder CreateBuilder(Rectangle prototype) {
- return new Builder(prototype);
+ public override int GetHashCode() {
+ int hash = 1;
+ if (lo_ != null) hash ^= Lo.GetHashCode();
+ if (hi_ != null) hash ^= Hi.GetHashCode();
+ return hash;
}
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- public sealed partial class Builder : pb::GeneratedBuilder<Rectangle, Builder> {
- protected override Builder ThisBuilder {
- get { return this; }
- }
- public Builder() {
- result = DefaultInstance;
- resultIsReadOnly = true;
- }
- internal Builder(Rectangle cloneFrom) {
- result = cloneFrom;
- resultIsReadOnly = true;
- }
-
- private bool resultIsReadOnly;
- private Rectangle result;
-
- private Rectangle PrepareBuilder() {
- if (resultIsReadOnly) {
- Rectangle original = result;
- result = new Rectangle();
- resultIsReadOnly = false;
- MergeFrom(original);
- }
- return result;
- }
-
- public override bool IsInitialized {
- get { return result.IsInitialized; }
- }
+ public override string ToString() {
+ return pb::JsonFormatter.Default.Format(this);
+ }
- protected override Rectangle MessageBeingBuilt {
- get { return PrepareBuilder(); }
+ public void WriteTo(pb::CodedOutputStream output) {
+ if (lo_ != null) {
+ output.WriteRawTag(10);
+ output.WriteMessage(Lo);
}
-
- public override Builder Clear() {
- result = DefaultInstance;
- resultIsReadOnly = true;
- return this;
+ if (hi_ != null) {
+ output.WriteRawTag(18);
+ output.WriteMessage(Hi);
}
+ }
- public override Builder Clone() {
- if (resultIsReadOnly) {
- return new Builder(result);
- } else {
- return new Builder().MergeFrom(result);
- }
+ public int CalculateSize() {
+ int size = 0;
+ if (lo_ != null) {
+ size += 1 + pb::CodedOutputStream.ComputeMessageSize(Lo);
}
-
- public override pbd::MessageDescriptor DescriptorForType {
- get { return global::examples.Rectangle.Descriptor; }
+ if (hi_ != null) {
+ size += 1 + pb::CodedOutputStream.ComputeMessageSize(Hi);
}
+ return size;
+ }
- public override Rectangle DefaultInstanceForType {
- get { return global::examples.Rectangle.DefaultInstance; }
+ public void MergeFrom(Rectangle other) {
+ if (other == null) {
+ return;
}
-
- public override Rectangle BuildPartial() {
- if (resultIsReadOnly) {
- return result;
+ if (other.lo_ != null) {
+ if (lo_ == null) {
+ lo_ = new global::Examples.Point();
}
- resultIsReadOnly = true;
- return result.MakeReadOnly();
+ Lo.MergeFrom(other.Lo);
}
-
- public override Builder MergeFrom(pb::IMessage other) {
- if (other is Rectangle) {
- return MergeFrom((Rectangle) other);
- } else {
- base.MergeFrom(other);
- return this;
+ if (other.hi_ != null) {
+ if (hi_ == null) {
+ hi_ = new global::Examples.Point();
}
+ Hi.MergeFrom(other.Hi);
}
+ }
- public override Builder MergeFrom(Rectangle other) {
- if (other == global::examples.Rectangle.DefaultInstance) return this;
- PrepareBuilder();
- if (other.HasLo) {
- MergeLo(other.Lo);
- }
- if (other.HasHi) {
- MergeHi(other.Hi);
- }
- this.MergeUnknownFields(other.UnknownFields);
- return this;
- }
-
- public override Builder MergeFrom(pb::ICodedInputStream input) {
- return MergeFrom(input, pb::ExtensionRegistry.Empty);
- }
-
- public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
- PrepareBuilder();
- pb::UnknownFieldSet.Builder unknownFields = null;
- uint tag;
- string field_name;
- while (input.ReadTag(out tag, out field_name)) {
- if(tag == 0 && field_name != null) {
- int field_ordinal = global::System.Array.BinarySearch(_rectangleFieldNames, field_name, global::System.StringComparer.Ordinal);
- if(field_ordinal >= 0)
- tag = _rectangleFieldTags[field_ordinal];
- else {
- if (unknownFields == null) {
- unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
- }
- ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
- continue;
+ public void MergeFrom(pb::CodedInputStream input) {
+ uint tag;
+ while ((tag = input.ReadTag()) != 0) {
+ switch(tag) {
+ default:
+ input.SkipLastField();
+ break;
+ case 10: {
+ if (lo_ == null) {
+ lo_ = new global::Examples.Point();
}
+ input.ReadMessage(lo_);
+ break;
}
- switch (tag) {
- case 0: {
- throw pb::InvalidProtocolBufferException.InvalidTag();
- }
- default: {
- if (pb::WireFormat.IsEndGroupTag(tag)) {
- if (unknownFields != null) {
- this.UnknownFields = unknownFields.Build();
- }
- return this;
- }
- if (unknownFields == null) {
- unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
- }
- ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
- break;
- }
- case 10: {
- global::examples.Point.Builder subBuilder = global::examples.Point.CreateBuilder();
- if (result.hasLo) {
- subBuilder.MergeFrom(Lo);
- }
- input.ReadMessage(subBuilder, extensionRegistry);
- Lo = subBuilder.BuildPartial();
- break;
- }
- case 18: {
- global::examples.Point.Builder subBuilder = global::examples.Point.CreateBuilder();
- if (result.hasHi) {
- subBuilder.MergeFrom(Hi);
- }
- input.ReadMessage(subBuilder, extensionRegistry);
- Hi = subBuilder.BuildPartial();
- break;
+ case 18: {
+ if (hi_ == null) {
+ hi_ = new global::Examples.Point();
}
+ input.ReadMessage(hi_);
+ break;
}
}
-
- if (unknownFields != null) {
- this.UnknownFields = unknownFields.Build();
- }
- return this;
- }
-
-
- public bool HasLo {
- get { return result.hasLo; }
- }
- public global::examples.Point Lo {
- get { return result.Lo; }
- set { SetLo(value); }
- }
- public Builder SetLo(global::examples.Point value) {
- pb::ThrowHelper.ThrowIfNull(value, "value");
- PrepareBuilder();
- result.hasLo = true;
- result.lo_ = value;
- return this;
- }
- public Builder SetLo(global::examples.Point.Builder builderForValue) {
- pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue");
- PrepareBuilder();
- result.hasLo = true;
- result.lo_ = builderForValue.Build();
- return this;
- }
- public Builder MergeLo(global::examples.Point value) {
- pb::ThrowHelper.ThrowIfNull(value, "value");
- PrepareBuilder();
- if (result.hasLo &&
- result.lo_ != global::examples.Point.DefaultInstance) {
- result.lo_ = global::examples.Point.CreateBuilder(result.lo_).MergeFrom(value).BuildPartial();
- } else {
- result.lo_ = value;
- }
- result.hasLo = true;
- return this;
- }
- public Builder ClearLo() {
- PrepareBuilder();
- result.hasLo = false;
- result.lo_ = null;
- return this;
- }
-
- public bool HasHi {
- get { return result.hasHi; }
- }
- public global::examples.Point Hi {
- get { return result.Hi; }
- set { SetHi(value); }
- }
- public Builder SetHi(global::examples.Point value) {
- pb::ThrowHelper.ThrowIfNull(value, "value");
- PrepareBuilder();
- result.hasHi = true;
- result.hi_ = value;
- return this;
- }
- public Builder SetHi(global::examples.Point.Builder builderForValue) {
- pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue");
- PrepareBuilder();
- result.hasHi = true;
- result.hi_ = builderForValue.Build();
- return this;
- }
- public Builder MergeHi(global::examples.Point value) {
- pb::ThrowHelper.ThrowIfNull(value, "value");
- PrepareBuilder();
- if (result.hasHi &&
- result.hi_ != global::examples.Point.DefaultInstance) {
- result.hi_ = global::examples.Point.CreateBuilder(result.hi_).MergeFrom(value).BuildPartial();
- } else {
- result.hi_ = value;
- }
- result.hasHi = true;
- return this;
}
- public Builder ClearHi() {
- PrepareBuilder();
- result.hasHi = false;
- result.hi_ = null;
- return this;
- }
- }
- static Rectangle() {
- object.ReferenceEquals(global::examples.Proto.RouteGuide.Descriptor, null);
}
+
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- public sealed partial class Feature : pb::GeneratedMessage<Feature, Feature.Builder> {
- private Feature() { }
- private static readonly Feature defaultInstance = new Feature().MakeReadOnly();
- private static readonly string[] _featureFieldNames = new string[] { "location", "name" };
- private static readonly uint[] _featureFieldTags = new uint[] { 18, 10 };
- public static Feature DefaultInstance {
- get { return defaultInstance; }
+ public sealed partial class Feature : pb::IMessage<Feature> {
+ private static readonly pb::MessageParser<Feature> _parser = new pb::MessageParser<Feature>(() => new Feature());
+ public static pb::MessageParser<Feature> Parser { get { return _parser; } }
+
+ public static pbr::MessageDescriptor Descriptor {
+ get { return global::Examples.Proto.RouteGuide.Descriptor.MessageTypes[2]; }
}
- public override Feature DefaultInstanceForType {
- get { return DefaultInstance; }
+ pbr::MessageDescriptor pb::IMessage.Descriptor {
+ get { return Descriptor; }
}
- protected override Feature ThisMessage {
- get { return this; }
+ public Feature() {
+ OnConstruction();
}
- public static pbd::MessageDescriptor Descriptor {
- get { return global::examples.Proto.RouteGuide.internal__static_examples_Feature__Descriptor; }
+ partial void OnConstruction();
+
+ public Feature(Feature other) : this() {
+ name_ = other.name_;
+ Location = other.location_ != null ? other.Location.Clone() : null;
}
- protected override pb::FieldAccess.FieldAccessorTable<Feature, Feature.Builder> InternalFieldAccessors {
- get { return global::examples.Proto.RouteGuide.internal__static_examples_Feature__FieldAccessorTable; }
+ public Feature Clone() {
+ return new Feature(this);
}
public const int NameFieldNumber = 1;
- private bool hasName;
private string name_ = "";
- public bool HasName {
- get { return hasName; }
- }
public string Name {
get { return name_; }
- }
-
- public const int LocationFieldNumber = 2;
- private bool hasLocation;
- private global::examples.Point location_;
- public bool HasLocation {
- get { return hasLocation; }
- }
- public global::examples.Point Location {
- get { return location_ ?? global::examples.Point.DefaultInstance; }
- }
-
- public override bool IsInitialized {
- get {
- return true;
+ set {
+ name_ = pb::Preconditions.CheckNotNull(value, "value");
}
}
- public override void WriteTo(pb::ICodedOutputStream output) {
- CalcSerializedSize();
- string[] field_names = _featureFieldNames;
- if (hasName) {
- output.WriteString(1, field_names[1], Name);
- }
- if (hasLocation) {
- output.WriteMessage(2, field_names[0], Location);
+ public const int LocationFieldNumber = 2;
+ private global::Examples.Point location_;
+ public global::Examples.Point Location {
+ get { return location_; }
+ set {
+ location_ = value;
}
- UnknownFields.WriteTo(output);
}
- private int memoizedSerializedSize = -1;
- public override int SerializedSize {
- get {
- int size = memoizedSerializedSize;
- if (size != -1) return size;
- return CalcSerializedSize();
- }
+ public override bool Equals(object other) {
+ return Equals(other as Feature);
}
- private int CalcSerializedSize() {
- int size = memoizedSerializedSize;
- if (size != -1) return size;
-
- size = 0;
- if (hasName) {
- size += pb::CodedOutputStream.ComputeStringSize(1, Name);
+ public bool Equals(Feature other) {
+ if (ReferenceEquals(other, null)) {
+ return false;
}
- if (hasLocation) {
- size += pb::CodedOutputStream.ComputeMessageSize(2, Location);
+ if (ReferenceEquals(other, this)) {
+ return true;
}
- size += UnknownFields.SerializedSize;
- memoizedSerializedSize = size;
- return size;
- }
- public static Feature ParseFrom(pb::ByteString data) {
- return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed();
- }
- public static Feature ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) {
- return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed();
- }
- public static Feature ParseFrom(byte[] data) {
- return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed();
- }
- public static Feature ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) {
- return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed();
- }
- public static Feature ParseFrom(global::System.IO.Stream input) {
- return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed();
- }
- public static Feature ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) {
- return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
- }
- public static Feature ParseDelimitedFrom(global::System.IO.Stream input) {
- return CreateBuilder().MergeDelimitedFrom(input).BuildParsed();
- }
- public static Feature ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) {
- return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed();
- }
- public static Feature ParseFrom(pb::ICodedInputStream input) {
- return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed();
- }
- public static Feature ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
- return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
- }
- private Feature MakeReadOnly() {
- return this;
+ if (Name != other.Name) return false;
+ if (!object.Equals(Location, other.Location)) return false;
+ return true;
}
- public static Builder CreateBuilder() { return new Builder(); }
- public override Builder ToBuilder() { return CreateBuilder(this); }
- public override Builder CreateBuilderForType() { return new Builder(); }
- public static Builder CreateBuilder(Feature prototype) {
- return new Builder(prototype);
+ public override int GetHashCode() {
+ int hash = 1;
+ if (Name.Length != 0) hash ^= Name.GetHashCode();
+ if (location_ != null) hash ^= Location.GetHashCode();
+ return hash;
}
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- public sealed partial class Builder : pb::GeneratedBuilder<Feature, Builder> {
- protected override Builder ThisBuilder {
- get { return this; }
- }
- public Builder() {
- result = DefaultInstance;
- resultIsReadOnly = true;
- }
- internal Builder(Feature cloneFrom) {
- result = cloneFrom;
- resultIsReadOnly = true;
- }
-
- private bool resultIsReadOnly;
- private Feature result;
-
- private Feature PrepareBuilder() {
- if (resultIsReadOnly) {
- Feature original = result;
- result = new Feature();
- resultIsReadOnly = false;
- MergeFrom(original);
- }
- return result;
- }
-
- public override bool IsInitialized {
- get { return result.IsInitialized; }
- }
+ public override string ToString() {
+ return pb::JsonFormatter.Default.Format(this);
+ }
- protected override Feature MessageBeingBuilt {
- get { return PrepareBuilder(); }
+ public void WriteTo(pb::CodedOutputStream output) {
+ if (Name.Length != 0) {
+ output.WriteRawTag(10);
+ output.WriteString(Name);
}
-
- public override Builder Clear() {
- result = DefaultInstance;
- resultIsReadOnly = true;
- return this;
+ if (location_ != null) {
+ output.WriteRawTag(18);
+ output.WriteMessage(Location);
}
+ }
- public override Builder Clone() {
- if (resultIsReadOnly) {
- return new Builder(result);
- } else {
- return new Builder().MergeFrom(result);
- }
+ public int CalculateSize() {
+ int size = 0;
+ if (Name.Length != 0) {
+ size += 1 + pb::CodedOutputStream.ComputeStringSize(Name);
}
-
- public override pbd::MessageDescriptor DescriptorForType {
- get { return global::examples.Feature.Descriptor; }
+ if (location_ != null) {
+ size += 1 + pb::CodedOutputStream.ComputeMessageSize(Location);
}
+ return size;
+ }
- public override Feature DefaultInstanceForType {
- get { return global::examples.Feature.DefaultInstance; }
+ public void MergeFrom(Feature other) {
+ if (other == null) {
+ return;
}
-
- public override Feature BuildPartial() {
- if (resultIsReadOnly) {
- return result;
- }
- resultIsReadOnly = true;
- return result.MakeReadOnly();
+ if (other.Name.Length != 0) {
+ Name = other.Name;
}
-
- public override Builder MergeFrom(pb::IMessage other) {
- if (other is Feature) {
- return MergeFrom((Feature) other);
- } else {
- base.MergeFrom(other);
- return this;
+ if (other.location_ != null) {
+ if (location_ == null) {
+ location_ = new global::Examples.Point();
}
+ Location.MergeFrom(other.Location);
}
+ }
- public override Builder MergeFrom(Feature other) {
- if (other == global::examples.Feature.DefaultInstance) return this;
- PrepareBuilder();
- if (other.HasName) {
- Name = other.Name;
- }
- if (other.HasLocation) {
- MergeLocation(other.Location);
- }
- this.MergeUnknownFields(other.UnknownFields);
- return this;
- }
-
- public override Builder MergeFrom(pb::ICodedInputStream input) {
- return MergeFrom(input, pb::ExtensionRegistry.Empty);
- }
-
- public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
- PrepareBuilder();
- pb::UnknownFieldSet.Builder unknownFields = null;
- uint tag;
- string field_name;
- while (input.ReadTag(out tag, out field_name)) {
- if(tag == 0 && field_name != null) {
- int field_ordinal = global::System.Array.BinarySearch(_featureFieldNames, field_name, global::System.StringComparer.Ordinal);
- if(field_ordinal >= 0)
- tag = _featureFieldTags[field_ordinal];
- else {
- if (unknownFields == null) {
- unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
- }
- ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
- continue;
- }
+ public void MergeFrom(pb::CodedInputStream input) {
+ uint tag;
+ while ((tag = input.ReadTag()) != 0) {
+ switch(tag) {
+ default:
+ input.SkipLastField();
+ break;
+ case 10: {
+ Name = input.ReadString();
+ break;
}
- switch (tag) {
- case 0: {
- throw pb::InvalidProtocolBufferException.InvalidTag();
- }
- default: {
- if (pb::WireFormat.IsEndGroupTag(tag)) {
- if (unknownFields != null) {
- this.UnknownFields = unknownFields.Build();
- }
- return this;
- }
- if (unknownFields == null) {
- unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
- }
- ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
- break;
- }
- case 10: {
- result.hasName = input.ReadString(ref result.name_);
- break;
- }
- case 18: {
- global::examples.Point.Builder subBuilder = global::examples.Point.CreateBuilder();
- if (result.hasLocation) {
- subBuilder.MergeFrom(Location);
- }
- input.ReadMessage(subBuilder, extensionRegistry);
- Location = subBuilder.BuildPartial();
- break;
+ case 18: {
+ if (location_ == null) {
+ location_ = new global::Examples.Point();
}
+ input.ReadMessage(location_);
+ break;
}
}
-
- if (unknownFields != null) {
- this.UnknownFields = unknownFields.Build();
- }
- return this;
- }
-
-
- public bool HasName {
- get { return result.hasName; }
- }
- public string Name {
- get { return result.Name; }
- set { SetName(value); }
- }
- public Builder SetName(string value) {
- pb::ThrowHelper.ThrowIfNull(value, "value");
- PrepareBuilder();
- result.hasName = true;
- result.name_ = value;
- return this;
- }
- public Builder ClearName() {
- PrepareBuilder();
- result.hasName = false;
- result.name_ = "";
- return this;
- }
-
- public bool HasLocation {
- get { return result.hasLocation; }
- }
- public global::examples.Point Location {
- get { return result.Location; }
- set { SetLocation(value); }
- }
- public Builder SetLocation(global::examples.Point value) {
- pb::ThrowHelper.ThrowIfNull(value, "value");
- PrepareBuilder();
- result.hasLocation = true;
- result.location_ = value;
- return this;
- }
- public Builder SetLocation(global::examples.Point.Builder builderForValue) {
- pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue");
- PrepareBuilder();
- result.hasLocation = true;
- result.location_ = builderForValue.Build();
- return this;
- }
- public Builder MergeLocation(global::examples.Point value) {
- pb::ThrowHelper.ThrowIfNull(value, "value");
- PrepareBuilder();
- if (result.hasLocation &&
- result.location_ != global::examples.Point.DefaultInstance) {
- result.location_ = global::examples.Point.CreateBuilder(result.location_).MergeFrom(value).BuildPartial();
- } else {
- result.location_ = value;
- }
- result.hasLocation = true;
- return this;
- }
- public Builder ClearLocation() {
- PrepareBuilder();
- result.hasLocation = false;
- result.location_ = null;
- return this;
}
}
- static Feature() {
- object.ReferenceEquals(global::examples.Proto.RouteGuide.Descriptor, null);
- }
+
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- public sealed partial class RouteNote : pb::GeneratedMessage<RouteNote, RouteNote.Builder> {
- private RouteNote() { }
- private static readonly RouteNote defaultInstance = new RouteNote().MakeReadOnly();
- private static readonly string[] _routeNoteFieldNames = new string[] { "location", "message" };
- private static readonly uint[] _routeNoteFieldTags = new uint[] { 10, 18 };
- public static RouteNote DefaultInstance {
- get { return defaultInstance; }
+ public sealed partial class RouteNote : pb::IMessage<RouteNote> {
+ private static readonly pb::MessageParser<RouteNote> _parser = new pb::MessageParser<RouteNote>(() => new RouteNote());
+ public static pb::MessageParser<RouteNote> Parser { get { return _parser; } }
+
+ public static pbr::MessageDescriptor Descriptor {
+ get { return global::Examples.Proto.RouteGuide.Descriptor.MessageTypes[3]; }
}
- public override RouteNote DefaultInstanceForType {
- get { return DefaultInstance; }
+ pbr::MessageDescriptor pb::IMessage.Descriptor {
+ get { return Descriptor; }
}
- protected override RouteNote ThisMessage {
- get { return this; }
+ public RouteNote() {
+ OnConstruction();
}
- public static pbd::MessageDescriptor Descriptor {
- get { return global::examples.Proto.RouteGuide.internal__static_examples_RouteNote__Descriptor; }
+ partial void OnConstruction();
+
+ public RouteNote(RouteNote other) : this() {
+ Location = other.location_ != null ? other.Location.Clone() : null;
+ message_ = other.message_;
}
- protected override pb::FieldAccess.FieldAccessorTable<RouteNote, RouteNote.Builder> InternalFieldAccessors {
- get { return global::examples.Proto.RouteGuide.internal__static_examples_RouteNote__FieldAccessorTable; }
+ public RouteNote Clone() {
+ return new RouteNote(this);
}
public const int LocationFieldNumber = 1;
- private bool hasLocation;
- private global::examples.Point location_;
- public bool HasLocation {
- get { return hasLocation; }
- }
- public global::examples.Point Location {
- get { return location_ ?? global::examples.Point.DefaultInstance; }
+ private global::Examples.Point location_;
+ public global::Examples.Point Location {
+ get { return location_; }
+ set {
+ location_ = value;
+ }
}
public const int MessageFieldNumber = 2;
- private bool hasMessage;
private string message_ = "";
- public bool HasMessage {
- get { return hasMessage; }
- }
public string Message {
get { return message_; }
- }
-
- public override bool IsInitialized {
- get {
- return true;
+ set {
+ message_ = pb::Preconditions.CheckNotNull(value, "value");
}
}
- public override void WriteTo(pb::ICodedOutputStream output) {
- CalcSerializedSize();
- string[] field_names = _routeNoteFieldNames;
- if (hasLocation) {
- output.WriteMessage(1, field_names[0], Location);
- }
- if (hasMessage) {
- output.WriteString(2, field_names[1], Message);
- }
- UnknownFields.WriteTo(output);
+ public override bool Equals(object other) {
+ return Equals(other as RouteNote);
}
- private int memoizedSerializedSize = -1;
- public override int SerializedSize {
- get {
- int size = memoizedSerializedSize;
- if (size != -1) return size;
- return CalcSerializedSize();
+ public bool Equals(RouteNote other) {
+ if (ReferenceEquals(other, null)) {
+ return false;
}
- }
-
- private int CalcSerializedSize() {
- int size = memoizedSerializedSize;
- if (size != -1) return size;
-
- size = 0;
- if (hasLocation) {
- size += pb::CodedOutputStream.ComputeMessageSize(1, Location);
- }
- if (hasMessage) {
- size += pb::CodedOutputStream.ComputeStringSize(2, Message);
+ if (ReferenceEquals(other, this)) {
+ return true;
}
- size += UnknownFields.SerializedSize;
- memoizedSerializedSize = size;
- return size;
- }
- public static RouteNote ParseFrom(pb::ByteString data) {
- return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed();
- }
- public static RouteNote ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) {
- return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed();
- }
- public static RouteNote ParseFrom(byte[] data) {
- return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed();
- }
- public static RouteNote ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) {
- return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed();
- }
- public static RouteNote ParseFrom(global::System.IO.Stream input) {
- return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed();
- }
- public static RouteNote ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) {
- return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
- }
- public static RouteNote ParseDelimitedFrom(global::System.IO.Stream input) {
- return CreateBuilder().MergeDelimitedFrom(input).BuildParsed();
- }
- public static RouteNote ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) {
- return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed();
- }
- public static RouteNote ParseFrom(pb::ICodedInputStream input) {
- return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed();
- }
- public static RouteNote ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
- return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
- }
- private RouteNote MakeReadOnly() {
- return this;
+ if (!object.Equals(Location, other.Location)) return false;
+ if (Message != other.Message) return false;
+ return true;
}
- public static Builder CreateBuilder() { return new Builder(); }
- public override Builder ToBuilder() { return CreateBuilder(this); }
- public override Builder CreateBuilderForType() { return new Builder(); }
- public static Builder CreateBuilder(RouteNote prototype) {
- return new Builder(prototype);
+ public override int GetHashCode() {
+ int hash = 1;
+ if (location_ != null) hash ^= Location.GetHashCode();
+ if (Message.Length != 0) hash ^= Message.GetHashCode();
+ return hash;
}
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- public sealed partial class Builder : pb::GeneratedBuilder<RouteNote, Builder> {
- protected override Builder ThisBuilder {
- get { return this; }
- }
- public Builder() {
- result = DefaultInstance;
- resultIsReadOnly = true;
- }
- internal Builder(RouteNote cloneFrom) {
- result = cloneFrom;
- resultIsReadOnly = true;
- }
-
- private bool resultIsReadOnly;
- private RouteNote result;
-
- private RouteNote PrepareBuilder() {
- if (resultIsReadOnly) {
- RouteNote original = result;
- result = new RouteNote();
- resultIsReadOnly = false;
- MergeFrom(original);
- }
- return result;
- }
-
- public override bool IsInitialized {
- get { return result.IsInitialized; }
- }
+ public override string ToString() {
+ return pb::JsonFormatter.Default.Format(this);
+ }
- protected override RouteNote MessageBeingBuilt {
- get { return PrepareBuilder(); }
+ public void WriteTo(pb::CodedOutputStream output) {
+ if (location_ != null) {
+ output.WriteRawTag(10);
+ output.WriteMessage(Location);
}
-
- public override Builder Clear() {
- result = DefaultInstance;
- resultIsReadOnly = true;
- return this;
+ if (Message.Length != 0) {
+ output.WriteRawTag(18);
+ output.WriteString(Message);
}
+ }
- public override Builder Clone() {
- if (resultIsReadOnly) {
- return new Builder(result);
- } else {
- return new Builder().MergeFrom(result);
- }
+ public int CalculateSize() {
+ int size = 0;
+ if (location_ != null) {
+ size += 1 + pb::CodedOutputStream.ComputeMessageSize(Location);
}
-
- public override pbd::MessageDescriptor DescriptorForType {
- get { return global::examples.RouteNote.Descriptor; }
+ if (Message.Length != 0) {
+ size += 1 + pb::CodedOutputStream.ComputeStringSize(Message);
}
+ return size;
+ }
- public override RouteNote DefaultInstanceForType {
- get { return global::examples.RouteNote.DefaultInstance; }
+ public void MergeFrom(RouteNote other) {
+ if (other == null) {
+ return;
}
-
- public override RouteNote BuildPartial() {
- if (resultIsReadOnly) {
- return result;
+ if (other.location_ != null) {
+ if (location_ == null) {
+ location_ = new global::Examples.Point();
}
- resultIsReadOnly = true;
- return result.MakeReadOnly();
+ Location.MergeFrom(other.Location);
}
-
- public override Builder MergeFrom(pb::IMessage other) {
- if (other is RouteNote) {
- return MergeFrom((RouteNote) other);
- } else {
- base.MergeFrom(other);
- return this;
- }
+ if (other.Message.Length != 0) {
+ Message = other.Message;
}
+ }
- public override Builder MergeFrom(RouteNote other) {
- if (other == global::examples.RouteNote.DefaultInstance) return this;
- PrepareBuilder();
- if (other.HasLocation) {
- MergeLocation(other.Location);
- }
- if (other.HasMessage) {
- Message = other.Message;
- }
- this.MergeUnknownFields(other.UnknownFields);
- return this;
- }
-
- public override Builder MergeFrom(pb::ICodedInputStream input) {
- return MergeFrom(input, pb::ExtensionRegistry.Empty);
- }
-
- public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
- PrepareBuilder();
- pb::UnknownFieldSet.Builder unknownFields = null;
- uint tag;
- string field_name;
- while (input.ReadTag(out tag, out field_name)) {
- if(tag == 0 && field_name != null) {
- int field_ordinal = global::System.Array.BinarySearch(_routeNoteFieldNames, field_name, global::System.StringComparer.Ordinal);
- if(field_ordinal >= 0)
- tag = _routeNoteFieldTags[field_ordinal];
- else {
- if (unknownFields == null) {
- unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
- }
- ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
- continue;
+ public void MergeFrom(pb::CodedInputStream input) {
+ uint tag;
+ while ((tag = input.ReadTag()) != 0) {
+ switch(tag) {
+ default:
+ input.SkipLastField();
+ break;
+ case 10: {
+ if (location_ == null) {
+ location_ = new global::Examples.Point();
}
+ input.ReadMessage(location_);
+ break;
}
- switch (tag) {
- case 0: {
- throw pb::InvalidProtocolBufferException.InvalidTag();
- }
- default: {
- if (pb::WireFormat.IsEndGroupTag(tag)) {
- if (unknownFields != null) {
- this.UnknownFields = unknownFields.Build();
- }
- return this;
- }
- if (unknownFields == null) {
- unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
- }
- ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
- break;
- }
- case 10: {
- global::examples.Point.Builder subBuilder = global::examples.Point.CreateBuilder();
- if (result.hasLocation) {
- subBuilder.MergeFrom(Location);
- }
- input.ReadMessage(subBuilder, extensionRegistry);
- Location = subBuilder.BuildPartial();
- break;
- }
- case 18: {
- result.hasMessage = input.ReadString(ref result.message_);
- break;
- }
+ case 18: {
+ Message = input.ReadString();
+ break;
}
}
-
- if (unknownFields != null) {
- this.UnknownFields = unknownFields.Build();
- }
- return this;
- }
-
-
- public bool HasLocation {
- get { return result.hasLocation; }
- }
- public global::examples.Point Location {
- get { return result.Location; }
- set { SetLocation(value); }
- }
- public Builder SetLocation(global::examples.Point value) {
- pb::ThrowHelper.ThrowIfNull(value, "value");
- PrepareBuilder();
- result.hasLocation = true;
- result.location_ = value;
- return this;
- }
- public Builder SetLocation(global::examples.Point.Builder builderForValue) {
- pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue");
- PrepareBuilder();
- result.hasLocation = true;
- result.location_ = builderForValue.Build();
- return this;
- }
- public Builder MergeLocation(global::examples.Point value) {
- pb::ThrowHelper.ThrowIfNull(value, "value");
- PrepareBuilder();
- if (result.hasLocation &&
- result.location_ != global::examples.Point.DefaultInstance) {
- result.location_ = global::examples.Point.CreateBuilder(result.location_).MergeFrom(value).BuildPartial();
- } else {
- result.location_ = value;
- }
- result.hasLocation = true;
- return this;
- }
- public Builder ClearLocation() {
- PrepareBuilder();
- result.hasLocation = false;
- result.location_ = null;
- return this;
- }
-
- public bool HasMessage {
- get { return result.hasMessage; }
- }
- public string Message {
- get { return result.Message; }
- set { SetMessage(value); }
- }
- public Builder SetMessage(string value) {
- pb::ThrowHelper.ThrowIfNull(value, "value");
- PrepareBuilder();
- result.hasMessage = true;
- result.message_ = value;
- return this;
- }
- public Builder ClearMessage() {
- PrepareBuilder();
- result.hasMessage = false;
- result.message_ = "";
- return this;
}
}
- static RouteNote() {
- object.ReferenceEquals(global::examples.Proto.RouteGuide.Descriptor, null);
- }
+
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- public sealed partial class RouteSummary : pb::GeneratedMessage<RouteSummary, RouteSummary.Builder> {
- private RouteSummary() { }
- private static readonly RouteSummary defaultInstance = new RouteSummary().MakeReadOnly();
- private static readonly string[] _routeSummaryFieldNames = new string[] { "distance", "elapsed_time", "feature_count", "point_count" };
- private static readonly uint[] _routeSummaryFieldTags = new uint[] { 24, 32, 16, 8 };
- public static RouteSummary DefaultInstance {
- get { return defaultInstance; }
+ public sealed partial class RouteSummary : pb::IMessage<RouteSummary> {
+ private static readonly pb::MessageParser<RouteSummary> _parser = new pb::MessageParser<RouteSummary>(() => new RouteSummary());
+ public static pb::MessageParser<RouteSummary> Parser { get { return _parser; } }
+
+ public static pbr::MessageDescriptor Descriptor {
+ get { return global::Examples.Proto.RouteGuide.Descriptor.MessageTypes[4]; }
}
- public override RouteSummary DefaultInstanceForType {
- get { return DefaultInstance; }
+ pbr::MessageDescriptor pb::IMessage.Descriptor {
+ get { return Descriptor; }
}
- protected override RouteSummary ThisMessage {
- get { return this; }
+ public RouteSummary() {
+ OnConstruction();
}
- public static pbd::MessageDescriptor Descriptor {
- get { return global::examples.Proto.RouteGuide.internal__static_examples_RouteSummary__Descriptor; }
+ partial void OnConstruction();
+
+ public RouteSummary(RouteSummary other) : this() {
+ pointCount_ = other.pointCount_;
+ featureCount_ = other.featureCount_;
+ distance_ = other.distance_;
+ elapsedTime_ = other.elapsedTime_;
}
- protected override pb::FieldAccess.FieldAccessorTable<RouteSummary, RouteSummary.Builder> InternalFieldAccessors {
- get { return global::examples.Proto.RouteGuide.internal__static_examples_RouteSummary__FieldAccessorTable; }
+ public RouteSummary Clone() {
+ return new RouteSummary(this);
}
public const int PointCountFieldNumber = 1;
- private bool hasPointCount;
private int pointCount_;
- public bool HasPointCount {
- get { return hasPointCount; }
- }
public int PointCount {
get { return pointCount_; }
+ set {
+ pointCount_ = value;
+ }
}
public const int FeatureCountFieldNumber = 2;
- private bool hasFeatureCount;
private int featureCount_;
- public bool HasFeatureCount {
- get { return hasFeatureCount; }
- }
public int FeatureCount {
get { return featureCount_; }
+ set {
+ featureCount_ = value;
+ }
}
public const int DistanceFieldNumber = 3;
- private bool hasDistance;
private int distance_;
- public bool HasDistance {
- get { return hasDistance; }
- }
public int Distance {
get { return distance_; }
+ set {
+ distance_ = value;
+ }
}
public const int ElapsedTimeFieldNumber = 4;
- private bool hasElapsedTime;
private int elapsedTime_;
- public bool HasElapsedTime {
- get { return hasElapsedTime; }
- }
public int ElapsedTime {
get { return elapsedTime_; }
+ set {
+ elapsedTime_ = value;
+ }
}
- public override bool IsInitialized {
- get {
- return true;
- }
+ public override bool Equals(object other) {
+ return Equals(other as RouteSummary);
}
- public override void WriteTo(pb::ICodedOutputStream output) {
- CalcSerializedSize();
- string[] field_names = _routeSummaryFieldNames;
- if (hasPointCount) {
- output.WriteInt32(1, field_names[3], PointCount);
- }
- if (hasFeatureCount) {
- output.WriteInt32(2, field_names[2], FeatureCount);
- }
- if (hasDistance) {
- output.WriteInt32(3, field_names[0], Distance);
+ public bool Equals(RouteSummary other) {
+ if (ReferenceEquals(other, null)) {
+ return false;
}
- if (hasElapsedTime) {
- output.WriteInt32(4, field_names[1], ElapsedTime);
+ if (ReferenceEquals(other, this)) {
+ return true;
}
- UnknownFields.WriteTo(output);
+ if (PointCount != other.PointCount) return false;
+ if (FeatureCount != other.FeatureCount) return false;
+ if (Distance != other.Distance) return false;
+ if (ElapsedTime != other.ElapsedTime) return false;
+ return true;
}
- private int memoizedSerializedSize = -1;
- public override int SerializedSize {
- get {
- int size = memoizedSerializedSize;
- if (size != -1) return size;
- return CalcSerializedSize();
- }
+ public override int GetHashCode() {
+ int hash = 1;
+ if (PointCount != 0) hash ^= PointCount.GetHashCode();
+ if (FeatureCount != 0) hash ^= FeatureCount.GetHashCode();
+ if (Distance != 0) hash ^= Distance.GetHashCode();
+ if (ElapsedTime != 0) hash ^= ElapsedTime.GetHashCode();
+ return hash;
}
- private int CalcSerializedSize() {
- int size = memoizedSerializedSize;
- if (size != -1) return size;
+ public override string ToString() {
+ return pb::JsonFormatter.Default.Format(this);
+ }
- size = 0;
- if (hasPointCount) {
- size += pb::CodedOutputStream.ComputeInt32Size(1, PointCount);
+ public void WriteTo(pb::CodedOutputStream output) {
+ if (PointCount != 0) {
+ output.WriteRawTag(8);
+ output.WriteInt32(PointCount);
}
- if (hasFeatureCount) {
- size += pb::CodedOutputStream.ComputeInt32Size(2, FeatureCount);
+ if (FeatureCount != 0) {
+ output.WriteRawTag(16);
+ output.WriteInt32(FeatureCount);
}
- if (hasDistance) {
- size += pb::CodedOutputStream.ComputeInt32Size(3, Distance);
+ if (Distance != 0) {
+ output.WriteRawTag(24);
+ output.WriteInt32(Distance);
}
- if (hasElapsedTime) {
- size += pb::CodedOutputStream.ComputeInt32Size(4, ElapsedTime);
+ if (ElapsedTime != 0) {
+ output.WriteRawTag(32);
+ output.WriteInt32(ElapsedTime);
}
- size += UnknownFields.SerializedSize;
- memoizedSerializedSize = size;
- return size;
- }
- public static RouteSummary ParseFrom(pb::ByteString data) {
- return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed();
- }
- public static RouteSummary ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) {
- return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed();
- }
- public static RouteSummary ParseFrom(byte[] data) {
- return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed();
- }
- public static RouteSummary ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) {
- return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed();
- }
- public static RouteSummary ParseFrom(global::System.IO.Stream input) {
- return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed();
- }
- public static RouteSummary ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) {
- return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
- }
- public static RouteSummary ParseDelimitedFrom(global::System.IO.Stream input) {
- return CreateBuilder().MergeDelimitedFrom(input).BuildParsed();
- }
- public static RouteSummary ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) {
- return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed();
- }
- public static RouteSummary ParseFrom(pb::ICodedInputStream input) {
- return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed();
- }
- public static RouteSummary ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
- return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
- }
- private RouteSummary MakeReadOnly() {
- return this;
- }
-
- public static Builder CreateBuilder() { return new Builder(); }
- public override Builder ToBuilder() { return CreateBuilder(this); }
- public override Builder CreateBuilderForType() { return new Builder(); }
- public static Builder CreateBuilder(RouteSummary prototype) {
- return new Builder(prototype);
}
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- public sealed partial class Builder : pb::GeneratedBuilder<RouteSummary, Builder> {
- protected override Builder ThisBuilder {
- get { return this; }
+ public int CalculateSize() {
+ int size = 0;
+ if (PointCount != 0) {
+ size += 1 + pb::CodedOutputStream.ComputeInt32Size(PointCount);
}
- public Builder() {
- result = DefaultInstance;
- resultIsReadOnly = true;
+ if (FeatureCount != 0) {
+ size += 1 + pb::CodedOutputStream.ComputeInt32Size(FeatureCount);
}
- internal Builder(RouteSummary cloneFrom) {
- result = cloneFrom;
- resultIsReadOnly = true;
+ if (Distance != 0) {
+ size += 1 + pb::CodedOutputStream.ComputeInt32Size(Distance);
}
-
- private bool resultIsReadOnly;
- private RouteSummary result;
-
- private RouteSummary PrepareBuilder() {
- if (resultIsReadOnly) {
- RouteSummary original = result;
- result = new RouteSummary();
- resultIsReadOnly = false;
- MergeFrom(original);
- }
- return result;
- }
-
- public override bool IsInitialized {
- get { return result.IsInitialized; }
- }
-
- protected override RouteSummary MessageBeingBuilt {
- get { return PrepareBuilder(); }
- }
-
- public override Builder Clear() {
- result = DefaultInstance;
- resultIsReadOnly = true;
- return this;
+ if (ElapsedTime != 0) {
+ size += 1 + pb::CodedOutputStream.ComputeInt32Size(ElapsedTime);
}
+ return size;
+ }
- public override Builder Clone() {
- if (resultIsReadOnly) {
- return new Builder(result);
- } else {
- return new Builder().MergeFrom(result);
- }
+ public void MergeFrom(RouteSummary other) {
+ if (other == null) {
+ return;
}
-
- public override pbd::MessageDescriptor DescriptorForType {
- get { return global::examples.RouteSummary.Descriptor; }
+ if (other.PointCount != 0) {
+ PointCount = other.PointCount;
}
-
- public override RouteSummary DefaultInstanceForType {
- get { return global::examples.RouteSummary.DefaultInstance; }
+ if (other.FeatureCount != 0) {
+ FeatureCount = other.FeatureCount;
}
-
- public override RouteSummary BuildPartial() {
- if (resultIsReadOnly) {
- return result;
- }
- resultIsReadOnly = true;
- return result.MakeReadOnly();
+ if (other.Distance != 0) {
+ Distance = other.Distance;
}
-
- public override Builder MergeFrom(pb::IMessage other) {
- if (other is RouteSummary) {
- return MergeFrom((RouteSummary) other);
- } else {
- base.MergeFrom(other);
- return this;
- }
+ if (other.ElapsedTime != 0) {
+ ElapsedTime = other.ElapsedTime;
}
+ }
- public override Builder MergeFrom(RouteSummary other) {
- if (other == global::examples.RouteSummary.DefaultInstance) return this;
- PrepareBuilder();
- if (other.HasPointCount) {
- PointCount = other.PointCount;
- }
- if (other.HasFeatureCount) {
- FeatureCount = other.FeatureCount;
- }
- if (other.HasDistance) {
- Distance = other.Distance;
- }
- if (other.HasElapsedTime) {
- ElapsedTime = other.ElapsedTime;
- }
- this.MergeUnknownFields(other.UnknownFields);
- return this;
- }
-
- public override Builder MergeFrom(pb::ICodedInputStream input) {
- return MergeFrom(input, pb::ExtensionRegistry.Empty);
- }
-
- public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
- PrepareBuilder();
- pb::UnknownFieldSet.Builder unknownFields = null;
- uint tag;
- string field_name;
- while (input.ReadTag(out tag, out field_name)) {
- if(tag == 0 && field_name != null) {
- int field_ordinal = global::System.Array.BinarySearch(_routeSummaryFieldNames, field_name, global::System.StringComparer.Ordinal);
- if(field_ordinal >= 0)
- tag = _routeSummaryFieldTags[field_ordinal];
- else {
- if (unknownFields == null) {
- unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
- }
- ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
- continue;
- }
+ public void MergeFrom(pb::CodedInputStream input) {
+ uint tag;
+ while ((tag = input.ReadTag()) != 0) {
+ switch(tag) {
+ default:
+ input.SkipLastField();
+ break;
+ case 8: {
+ PointCount = input.ReadInt32();
+ break;
}
- switch (tag) {
- case 0: {
- throw pb::InvalidProtocolBufferException.InvalidTag();
- }
- default: {
- if (pb::WireFormat.IsEndGroupTag(tag)) {
- if (unknownFields != null) {
- this.UnknownFields = unknownFields.Build();
- }
- return this;
- }
- if (unknownFields == null) {
- unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
- }
- ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
- break;
- }
- case 8: {
- result.hasPointCount = input.ReadInt32(ref result.pointCount_);
- break;
- }
- case 16: {
- result.hasFeatureCount = input.ReadInt32(ref result.featureCount_);
- break;
- }
- case 24: {
- result.hasDistance = input.ReadInt32(ref result.distance_);
- break;
- }
- case 32: {
- result.hasElapsedTime = input.ReadInt32(ref result.elapsedTime_);
- break;
- }
+ case 16: {
+ FeatureCount = input.ReadInt32();
+ break;
+ }
+ case 24: {
+ Distance = input.ReadInt32();
+ break;
+ }
+ case 32: {
+ ElapsedTime = input.ReadInt32();
+ break;
}
}
-
- if (unknownFields != null) {
- this.UnknownFields = unknownFields.Build();
- }
- return this;
- }
-
-
- public bool HasPointCount {
- get { return result.hasPointCount; }
- }
- public int PointCount {
- get { return result.PointCount; }
- set { SetPointCount(value); }
- }
- public Builder SetPointCount(int value) {
- PrepareBuilder();
- result.hasPointCount = true;
- result.pointCount_ = value;
- return this;
- }
- public Builder ClearPointCount() {
- PrepareBuilder();
- result.hasPointCount = false;
- result.pointCount_ = 0;
- return this;
- }
-
- public bool HasFeatureCount {
- get { return result.hasFeatureCount; }
- }
- public int FeatureCount {
- get { return result.FeatureCount; }
- set { SetFeatureCount(value); }
- }
- public Builder SetFeatureCount(int value) {
- PrepareBuilder();
- result.hasFeatureCount = true;
- result.featureCount_ = value;
- return this;
- }
- public Builder ClearFeatureCount() {
- PrepareBuilder();
- result.hasFeatureCount = false;
- result.featureCount_ = 0;
- return this;
- }
-
- public bool HasDistance {
- get { return result.hasDistance; }
- }
- public int Distance {
- get { return result.Distance; }
- set { SetDistance(value); }
- }
- public Builder SetDistance(int value) {
- PrepareBuilder();
- result.hasDistance = true;
- result.distance_ = value;
- return this;
- }
- public Builder ClearDistance() {
- PrepareBuilder();
- result.hasDistance = false;
- result.distance_ = 0;
- return this;
- }
-
- public bool HasElapsedTime {
- get { return result.hasElapsedTime; }
- }
- public int ElapsedTime {
- get { return result.ElapsedTime; }
- set { SetElapsedTime(value); }
- }
- public Builder SetElapsedTime(int value) {
- PrepareBuilder();
- result.hasElapsedTime = true;
- result.elapsedTime_ = value;
- return this;
- }
- public Builder ClearElapsedTime() {
- PrepareBuilder();
- result.hasElapsedTime = false;
- result.elapsedTime_ = 0;
- return this;
}
}
- static RouteSummary() {
- object.ReferenceEquals(global::examples.Proto.RouteGuide.Descriptor, null);
- }
+
}
#endregion
diff --git a/examples/csharp/route_guide/RouteGuide/RouteGuide.csproj b/examples/csharp/route_guide/RouteGuide/RouteGuide.csproj
index 8358974aac..302a783aa4 100644
--- a/examples/csharp/route_guide/RouteGuide/RouteGuide.csproj
+++ b/examples/csharp/route_guide/RouteGuide/RouteGuide.csproj
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.props" Condition="Exists('..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.props')" />
- <Import Project="..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.props" Condition="Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.props')" />
+ <Import Project="..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props" Condition="Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props')" />
+ <Import Project="..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props" Condition="Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props')" />
<Import Project="..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.props" Condition="Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
@@ -14,7 +14,7 @@
<AssemblyName>RouteGuide</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
- <NuGetPackageImportStamp>214cccda</NuGetPackageImportStamp>
+ <NuGetPackageImportStamp>443bbc38</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@@ -34,25 +34,18 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
- <Reference Include="Google.ProtocolBuffers">
- <HintPath>..\packages\Google.ProtocolBuffers.2.4.1.555\lib\net40\Google.ProtocolBuffers.dll</HintPath>
+ <Reference Include="Google.Protobuf">
+ <HintPath>..\packages\Google.Protobuf.3.0.0-alpha4\lib\portable-net45+netcore45+wpa81+wp8\Google.Protobuf.dll</HintPath>
</Reference>
- <Reference Include="Google.ProtocolBuffers.Serialization">
- <HintPath>..\packages\Google.ProtocolBuffers.2.4.1.555\lib\net40\Google.ProtocolBuffers.Serialization.dll</HintPath>
- </Reference>
- <Reference Include="Grpc.Core, Version=0.6.5668.37363, Culture=neutral, processorArchitecture=MSIL">
+ <Reference Include="Grpc.Core, Version=0.7.0.0, Culture=neutral, PublicKeyToken=d754f35622e28bad, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\Grpc.Core.0.6.0\lib\net45\Grpc.Core.dll</HintPath>
+ <HintPath>..\packages\Grpc.Core.0.7.0\lib\net45\Grpc.Core.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Newtonsoft.Json.7.0.1-beta2\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
- <Reference Include="System.Collections.Immutable, Version=1.1.36.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\System.Collections.Immutable.1.1.36\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll</HintPath>
- </Reference>
<Reference Include="System.Core" />
<Reference Include="System.Interactive.Async">
<HintPath>..\packages\Ix-Async.1.2.3\lib\net45\System.Interactive.Async.dll</HintPath>
@@ -71,7 +64,6 @@
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
- <None Include="protos\route_guide.proto" />
<None Include="route_guide_db.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
@@ -83,14 +75,14 @@
</PropertyGroup>
<Error Condition="!Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.props'))" />
<Error Condition="!Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets'))" />
- <Error Condition="!Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.props'))" />
- <Error Condition="!Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.targets'))" />
- <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.props'))" />
- <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.targets'))" />
+ <Error Condition="!Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props'))" />
+ <Error Condition="!Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets'))" />
+ <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props'))" />
+ <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets'))" />
</Target>
<Import Project="..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets" Condition="Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets')" />
- <Import Project="..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.targets" Condition="Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.targets')" />
- <Import Project="..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.targets" Condition="Exists('..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.targets')" />
+ <Import Project="..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets" Condition="Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets')" />
+ <Import Project="..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets" Condition="Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
diff --git a/examples/csharp/route_guide/RouteGuide/RouteGuideGrpc.cs b/examples/csharp/route_guide/RouteGuide/RouteGuideGrpc.cs
index c4b3900dca..f2dc1c2ec0 100644
--- a/examples/csharp/route_guide/RouteGuide/RouteGuideGrpc.cs
+++ b/examples/csharp/route_guide/RouteGuide/RouteGuideGrpc.cs
@@ -7,93 +7,130 @@ using System.Threading;
using System.Threading.Tasks;
using Grpc.Core;
-namespace examples {
+namespace Examples {
public static class RouteGuide
{
static readonly string __ServiceName = "examples.RouteGuide";
- static readonly Marshaller<global::examples.Point> __Marshaller_Point = Marshallers.Create((arg) => arg.ToByteArray(), global::examples.Point.ParseFrom);
- static readonly Marshaller<global::examples.Feature> __Marshaller_Feature = Marshallers.Create((arg) => arg.ToByteArray(), global::examples.Feature.ParseFrom);
- static readonly Marshaller<global::examples.Rectangle> __Marshaller_Rectangle = Marshallers.Create((arg) => arg.ToByteArray(), global::examples.Rectangle.ParseFrom);
- static readonly Marshaller<global::examples.RouteSummary> __Marshaller_RouteSummary = Marshallers.Create((arg) => arg.ToByteArray(), global::examples.RouteSummary.ParseFrom);
- static readonly Marshaller<global::examples.RouteNote> __Marshaller_RouteNote = Marshallers.Create((arg) => arg.ToByteArray(), global::examples.RouteNote.ParseFrom);
+ static readonly Marshaller<global::Examples.Point> __Marshaller_Point = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Examples.Point.Parser.ParseFrom);
+ static readonly Marshaller<global::Examples.Feature> __Marshaller_Feature = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Examples.Feature.Parser.ParseFrom);
+ static readonly Marshaller<global::Examples.Rectangle> __Marshaller_Rectangle = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Examples.Rectangle.Parser.ParseFrom);
+ static readonly Marshaller<global::Examples.RouteSummary> __Marshaller_RouteSummary = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Examples.RouteSummary.Parser.ParseFrom);
+ static readonly Marshaller<global::Examples.RouteNote> __Marshaller_RouteNote = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Examples.RouteNote.Parser.ParseFrom);
- static readonly Method<global::examples.Point, global::examples.Feature> __Method_GetFeature = new Method<global::examples.Point, global::examples.Feature>(
+ static readonly Method<global::Examples.Point, global::Examples.Feature> __Method_GetFeature = new Method<global::Examples.Point, global::Examples.Feature>(
MethodType.Unary,
+ __ServiceName,
"GetFeature",
__Marshaller_Point,
__Marshaller_Feature);
- static readonly Method<global::examples.Rectangle, global::examples.Feature> __Method_ListFeatures = new Method<global::examples.Rectangle, global::examples.Feature>(
+ static readonly Method<global::Examples.Rectangle, global::Examples.Feature> __Method_ListFeatures = new Method<global::Examples.Rectangle, global::Examples.Feature>(
MethodType.ServerStreaming,
+ __ServiceName,
"ListFeatures",
__Marshaller_Rectangle,
__Marshaller_Feature);
- static readonly Method<global::examples.Point, global::examples.RouteSummary> __Method_RecordRoute = new Method<global::examples.Point, global::examples.RouteSummary>(
+ static readonly Method<global::Examples.Point, global::Examples.RouteSummary> __Method_RecordRoute = new Method<global::Examples.Point, global::Examples.RouteSummary>(
MethodType.ClientStreaming,
+ __ServiceName,
"RecordRoute",
__Marshaller_Point,
__Marshaller_RouteSummary);
- static readonly Method<global::examples.RouteNote, global::examples.RouteNote> __Method_RouteChat = new Method<global::examples.RouteNote, global::examples.RouteNote>(
+ static readonly Method<global::Examples.RouteNote, global::Examples.RouteNote> __Method_RouteChat = new Method<global::Examples.RouteNote, global::Examples.RouteNote>(
MethodType.DuplexStreaming,
+ __ServiceName,
"RouteChat",
__Marshaller_RouteNote,
__Marshaller_RouteNote);
- // client-side stub interface
+ // service descriptor
+ public static global::Google.Protobuf.Reflection.ServiceDescriptor Descriptor
+ {
+ get { return global::Examples.Proto.RouteGuide.Descriptor.Services[0]; }
+ }
+
+ // client interface
public interface IRouteGuideClient
{
- global::examples.Feature GetFeature(global::examples.Point request, CancellationToken token = default(CancellationToken));
- Task<global::examples.Feature> GetFeatureAsync(global::examples.Point request, CancellationToken token = default(CancellationToken));
- AsyncServerStreamingCall<global::examples.Feature> ListFeatures(global::examples.Rectangle request, CancellationToken token = default(CancellationToken));
- AsyncClientStreamingCall<global::examples.Point, global::examples.RouteSummary> RecordRoute(CancellationToken token = default(CancellationToken));
- AsyncDuplexStreamingCall<global::examples.RouteNote, global::examples.RouteNote> RouteChat(CancellationToken token = default(CancellationToken));
+ global::Examples.Feature GetFeature(global::Examples.Point request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken));
+ global::Examples.Feature GetFeature(global::Examples.Point request, CallOptions options);
+ AsyncUnaryCall<global::Examples.Feature> GetFeatureAsync(global::Examples.Point request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken));
+ AsyncUnaryCall<global::Examples.Feature> GetFeatureAsync(global::Examples.Point request, CallOptions options);
+ AsyncServerStreamingCall<global::Examples.Feature> ListFeatures(global::Examples.Rectangle request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken));
+ AsyncServerStreamingCall<global::Examples.Feature> ListFeatures(global::Examples.Rectangle request, CallOptions options);
+ AsyncClientStreamingCall<global::Examples.Point, global::Examples.RouteSummary> RecordRoute(Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken));
+ AsyncClientStreamingCall<global::Examples.Point, global::Examples.RouteSummary> RecordRoute(CallOptions options);
+ AsyncDuplexStreamingCall<global::Examples.RouteNote, global::Examples.RouteNote> RouteChat(Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken));
+ AsyncDuplexStreamingCall<global::Examples.RouteNote, global::Examples.RouteNote> RouteChat(CallOptions options);
}
// server-side interface
public interface IRouteGuide
{
- Task<global::examples.Feature> GetFeature(ServerCallContext context, global::examples.Point request);
- Task ListFeatures(ServerCallContext context, global::examples.Rectangle request, IServerStreamWriter<global::examples.Feature> responseStream);
- Task<global::examples.RouteSummary> RecordRoute(ServerCallContext context, IAsyncStreamReader<global::examples.Point> requestStream);
- Task RouteChat(ServerCallContext context, IAsyncStreamReader<global::examples.RouteNote> requestStream, IServerStreamWriter<global::examples.RouteNote> responseStream);
+ Task<global::Examples.Feature> GetFeature(global::Examples.Point request, ServerCallContext context);
+ Task ListFeatures(global::Examples.Rectangle request, IServerStreamWriter<global::Examples.Feature> responseStream, ServerCallContext context);
+ Task<global::Examples.RouteSummary> RecordRoute(IAsyncStreamReader<global::Examples.Point> requestStream, ServerCallContext context);
+ Task RouteChat(IAsyncStreamReader<global::Examples.RouteNote> requestStream, IServerStreamWriter<global::Examples.RouteNote> responseStream, ServerCallContext context);
}
// client stub
- public class RouteGuideClient : AbstractStub<RouteGuideClient, StubConfiguration>, IRouteGuideClient
+ public class RouteGuideClient : ClientBase, IRouteGuideClient
{
- public RouteGuideClient(Channel channel) : this(channel, StubConfiguration.Default)
+ public RouteGuideClient(Channel channel) : base(channel)
+ {
+ }
+ public global::Examples.Feature GetFeature(global::Examples.Point request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ var call = CreateCall(__Method_GetFeature, new CallOptions(headers, deadline, cancellationToken));
+ return Calls.BlockingUnaryCall(call, request);
+ }
+ public global::Examples.Feature GetFeature(global::Examples.Point request, CallOptions options)
{
+ var call = CreateCall(__Method_GetFeature, options);
+ return Calls.BlockingUnaryCall(call, request);
}
- public RouteGuideClient(Channel channel, StubConfiguration config) : base(channel, config)
+ public AsyncUnaryCall<global::Examples.Feature> GetFeatureAsync(global::Examples.Point request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken))
{
+ var call = CreateCall(__Method_GetFeature, new CallOptions(headers, deadline, cancellationToken));
+ return Calls.AsyncUnaryCall(call, request);
}
- public global::examples.Feature GetFeature(global::examples.Point request, CancellationToken token = default(CancellationToken))
+ public AsyncUnaryCall<global::Examples.Feature> GetFeatureAsync(global::Examples.Point request, CallOptions options)
{
- var call = CreateCall(__ServiceName, __Method_GetFeature);
- return Calls.BlockingUnaryCall(call, request, token);
+ var call = CreateCall(__Method_GetFeature, options);
+ return Calls.AsyncUnaryCall(call, request);
}
- public Task<global::examples.Feature> GetFeatureAsync(global::examples.Point request, CancellationToken token = default(CancellationToken))
+ public AsyncServerStreamingCall<global::Examples.Feature> ListFeatures(global::Examples.Rectangle request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken))
{
- var call = CreateCall(__ServiceName, __Method_GetFeature);
- return Calls.AsyncUnaryCall(call, request, token);
+ var call = CreateCall(__Method_ListFeatures, new CallOptions(headers, deadline, cancellationToken));
+ return Calls.AsyncServerStreamingCall(call, request);
}
- public AsyncServerStreamingCall<global::examples.Feature> ListFeatures(global::examples.Rectangle request, CancellationToken token = default(CancellationToken))
+ public AsyncServerStreamingCall<global::Examples.Feature> ListFeatures(global::Examples.Rectangle request, CallOptions options)
{
- var call = CreateCall(__ServiceName, __Method_ListFeatures);
- return Calls.AsyncServerStreamingCall(call, request, token);
+ var call = CreateCall(__Method_ListFeatures, options);
+ return Calls.AsyncServerStreamingCall(call, request);
}
- public AsyncClientStreamingCall<global::examples.Point, global::examples.RouteSummary> RecordRoute(CancellationToken token = default(CancellationToken))
+ public AsyncClientStreamingCall<global::Examples.Point, global::Examples.RouteSummary> RecordRoute(Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken))
{
- var call = CreateCall(__ServiceName, __Method_RecordRoute);
- return Calls.AsyncClientStreamingCall(call, token);
+ var call = CreateCall(__Method_RecordRoute, new CallOptions(headers, deadline, cancellationToken));
+ return Calls.AsyncClientStreamingCall(call);
}
- public AsyncDuplexStreamingCall<global::examples.RouteNote, global::examples.RouteNote> RouteChat(CancellationToken token = default(CancellationToken))
+ public AsyncClientStreamingCall<global::Examples.Point, global::Examples.RouteSummary> RecordRoute(CallOptions options)
{
- var call = CreateCall(__ServiceName, __Method_RouteChat);
- return Calls.AsyncDuplexStreamingCall(call, token);
+ var call = CreateCall(__Method_RecordRoute, options);
+ return Calls.AsyncClientStreamingCall(call);
+ }
+ public AsyncDuplexStreamingCall<global::Examples.RouteNote, global::Examples.RouteNote> RouteChat(Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ var call = CreateCall(__Method_RouteChat, new CallOptions(headers, deadline, cancellationToken));
+ return Calls.AsyncDuplexStreamingCall(call);
+ }
+ public AsyncDuplexStreamingCall<global::Examples.RouteNote, global::Examples.RouteNote> RouteChat(CallOptions options)
+ {
+ var call = CreateCall(__Method_RouteChat, options);
+ return Calls.AsyncDuplexStreamingCall(call);
}
}
@@ -107,17 +144,12 @@ namespace examples {
.AddMethod(__Method_RouteChat, serviceImpl.RouteChat).Build();
}
- // creates a new client stub
- public static IRouteGuideClient NewStub(Channel channel)
+ // creates a new client
+ public static RouteGuideClient NewClient(Channel channel)
{
return new RouteGuideClient(channel);
}
- // creates a new client stub
- public static IRouteGuideClient NewStub(Channel channel, StubConfiguration config)
- {
- return new RouteGuideClient(channel, config);
- }
}
}
#endregion
diff --git a/examples/csharp/route_guide/RouteGuide/RouteGuideUtil.cs b/examples/csharp/route_guide/RouteGuide/RouteGuideUtil.cs
index 6fb8b1e28a..21a0be43d2 100644
--- a/examples/csharp/route_guide/RouteGuide/RouteGuideUtil.cs
+++ b/examples/csharp/route_guide/RouteGuide/RouteGuideUtil.cs
@@ -7,8 +7,11 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
-namespace examples
+namespace Examples
{
+ /// <summary>
+ /// Utility methods for the route guide example.
+ /// </summary>
public static class RouteGuideUtil
{
public const string DefaultFeaturesFile = "route_guide_db.json";
@@ -18,22 +21,64 @@ namespace examples
/// <summary>
/// Indicates whether the given feature exists (i.e. has a valid name).
/// </summary>
- public static bool Exists(Feature feature)
+ public static bool Exists(this Feature feature)
{
return feature != null && (feature.Name.Length != 0);
}
- public static double GetLatitude(Point point)
+ public static double GetLatitude(this Point point)
{
return point.Latitude / CoordFactor;
}
- public static double GetLongitude(Point point)
+ public static double GetLongitude(this Point point)
{
return point.Longitude / CoordFactor;
}
/// <summary>
+ /// Calculate the distance between two points using the "haversine" formula.
+ /// This code was taken from http://www.movable-type.co.uk/scripts/latlong.html.
+ /// </summary>
+ /// <param name="start">the starting point</param>
+ /// <param name="end">the end point</param>
+ /// <returns>the distance between the points in meters</returns>
+ public static double GetDistance(this Point start, Point end)
+ {
+ double lat1 = start.GetLatitude();
+ double lat2 = end.GetLatitude();
+ double lon1 = start.GetLongitude();
+ double lon2 = end.GetLongitude();
+ int r = 6371000; // metres
+ double phi1 = ToRadians(lat1);
+ double phi2 = ToRadians(lat2);
+ double deltaPhi = ToRadians(lat2 - lat1);
+ double deltaLambda = ToRadians(lon2 - lon1);
+
+ double a = Math.Sin(deltaPhi / 2) * Math.Sin(deltaPhi / 2) + Math.Cos(phi1) * Math.Cos(phi2) * Math.Sin(deltaLambda / 2) * Math.Sin(deltaLambda / 2);
+ double c = 2 * Math.Atan2(Math.Sqrt(a), Math.Sqrt(1 - a));
+
+ return r * c;
+ }
+
+ /// <summary>
+ /// Returns <c>true</c> if rectangular area contains given point.
+ /// </summary>
+ public static bool Contains(this Rectangle rectangle, Point point)
+ {
+ int left = Math.Min(rectangle.Lo.Longitude, rectangle.Hi.Longitude);
+ int right = Math.Max(rectangle.Lo.Longitude, rectangle.Hi.Longitude);
+ int top = Math.Max(rectangle.Lo.Latitude, rectangle.Hi.Latitude);
+ int bottom = Math.Min(rectangle.Lo.Latitude, rectangle.Hi.Latitude);
+ return (point.Longitude >= left && point.Longitude <= right && point.Latitude >= bottom && point.Latitude <= top);
+ }
+
+ private static double ToRadians(double val)
+ {
+ return (Math.PI / 180) * val;
+ }
+
+ /// <summary>
/// Parses features from a JSON file.
/// </summary>
public static List<Feature> ParseFeatures(string filename)
@@ -41,13 +86,13 @@ namespace examples
var features = new List<Feature>();
var jsonFeatures = JsonConvert.DeserializeObject<List<JsonFeature>>(File.ReadAllText(filename));
-
foreach(var jsonFeature in jsonFeatures)
{
- features.Add(Feature.CreateBuilder().SetName(jsonFeature.name).SetLocation(
- Point.CreateBuilder()
- .SetLongitude(jsonFeature.location.longitude)
- .SetLatitude(jsonFeature.location.latitude).Build()).Build());
+ features.Add(new Feature
+ {
+ Name = jsonFeature.name,
+ Location = new Point { Longitude = jsonFeature.location.longitude, Latitude = jsonFeature.location.latitude}
+ });
}
return features;
}
diff --git a/examples/csharp/route_guide/RouteGuide/packages.config b/examples/csharp/route_guide/RouteGuide/packages.config
index 79abe0aa65..8cd2ee758d 100644
--- a/examples/csharp/route_guide/RouteGuide/packages.config
+++ b/examples/csharp/route_guide/RouteGuide/packages.config
@@ -1,12 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
- <package id="Google.ProtocolBuffers" version="2.4.1.555" targetFramework="net45" />
- <package id="Grpc" version="0.6.0" targetFramework="net45" />
- <package id="Grpc.Core" version="0.6.0" targetFramework="net45" />
- <package id="grpc.dependencies.openssl.redist" version="1.0.2.2" targetFramework="net45" />
+ <package id="Google.Protobuf" version="3.0.0-alpha4" targetFramework="net45" />
+ <package id="Grpc" version="0.7.0" targetFramework="net45" />
+ <package id="Grpc.Core" version="0.7.0" targetFramework="net45" />
+ <package id="grpc.dependencies.openssl.redist" version="1.0.2.3" targetFramework="net45" />
<package id="grpc.dependencies.zlib.redist" version="1.2.8.9" targetFramework="net45" />
- <package id="grpc.native.csharp_ext" version="0.10.0" targetFramework="net45" />
+ <package id="grpc.native.csharp_ext" version="0.11.0" targetFramework="net45" />
<package id="Ix-Async" version="1.2.3" targetFramework="net45" />
<package id="Newtonsoft.Json" version="7.0.1-beta2" targetFramework="net45" />
- <package id="System.Collections.Immutable" version="1.1.36" targetFramework="net45" />
</packages> \ No newline at end of file
diff --git a/examples/csharp/route_guide/RouteGuide/protos/route_guide.proto b/examples/csharp/route_guide/RouteGuide/protos/route_guide.proto
deleted file mode 100644
index f4110b5515..0000000000
--- a/examples/csharp/route_guide/RouteGuide/protos/route_guide.proto
+++ /dev/null
@@ -1,123 +0,0 @@
-// Copyright 2015, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-// TODO(jtattermusch): as of now, C# protobufs don't officially support
-// proto3.
-syntax = "proto2";
-
-package examples;
-
-// Interface exported by the server.
-service RouteGuide {
- // A simple RPC.
- //
- // Obtains the feature at a given position.
- //
- // A feature with an empty name is returned if there's no feature at the given
- // position.
- rpc GetFeature(Point) returns (Feature) {}
-
- // A server-to-client streaming RPC.
- //
- // Obtains the Features available within the given Rectangle. Results are
- // streamed rather than returned at once (e.g. in a response message with a
- // repeated field), as the rectangle may cover a large area and contain a
- // huge number of features.
- rpc ListFeatures(Rectangle) returns (stream Feature) {}
-
- // A client-to-server streaming RPC.
- //
- // Accepts a stream of Points on a route being traversed, returning a
- // RouteSummary when traversal is completed.
- rpc RecordRoute(stream Point) returns (RouteSummary) {}
-
- // A Bidirectional streaming RPC.
- //
- // Accepts a stream of RouteNotes sent while a route is being traversed,
- // while receiving other RouteNotes (e.g. from other users).
- rpc RouteChat(stream RouteNote) returns (stream RouteNote) {}
-}
-
-// Points are represented as latitude-longitude pairs in the E7 representation
-// (degrees multiplied by 10**7 and rounded to the nearest integer).
-// Latitudes should be in the range +/- 90 degrees and longitude should be in
-// the range +/- 180 degrees (inclusive).
-message Point {
- optional int32 latitude = 1;
- optional int32 longitude = 2;
-}
-
-// A latitude-longitude rectangle, represented as two diagonally opposite
-// points "lo" and "hi".
-message Rectangle {
- // One corner of the rectangle.
- optional Point lo = 1;
-
- // The other corner of the rectangle.
- optional Point hi = 2;
-}
-
-// A feature names something at a given point.
-//
-// If a feature could not be named, the name is empty.
-message Feature {
- // The name of the feature.
- optional string name = 1;
-
- // The point where the feature is detected.
- optional Point location = 2;
-}
-
-// A RouteNote is a message sent while at a given point.
-message RouteNote {
- // The location from which the message is sent.
- optional Point location = 1;
-
- // The message to be sent.
- optional string message = 2;
-}
-
-// A RouteSummary is received in response to a RecordRoute rpc.
-//
-// It contains the number of individual points received, the number of
-// detected features, and the total distance covered as the cumulative sum of
-// the distance between each point.
-message RouteSummary {
- // The number of points received.
- optional int32 point_count = 1;
-
- // The number of known features passed while traversing the route.
- optional int32 feature_count = 2;
-
- // The distance covered in metres.
- optional int32 distance = 3;
-
- // The duration of the traversal in seconds.
- optional int32 elapsed_time = 4;
-}
diff --git a/examples/csharp/route_guide/RouteGuideClient/Program.cs b/examples/csharp/route_guide/RouteGuideClient/Program.cs
index 0352c78020..4ddb526585 100644
--- a/examples/csharp/route_guide/RouteGuideClient/Program.cs
+++ b/examples/csharp/route_guide/RouteGuideClient/Program.cs
@@ -5,7 +5,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
-namespace examples
+namespace Examples
{
class Program
{
@@ -30,27 +30,24 @@ namespace examples
{
Log("*** GetFeature: lat={0} lon={1}", lat, lon);
- Point request = Point.CreateBuilder().SetLatitude(lat).SetLongitude(lon).Build();
+ Point request = new Point { Latitude = lat, Longitude = lon };
Feature feature = client.GetFeature(request);
- if (RouteGuideUtil.Exists(feature))
+ if (feature.Exists())
{
Log("Found feature called \"{0}\" at {1}, {2}",
- feature.Name,
- RouteGuideUtil.GetLatitude(feature.Location),
- RouteGuideUtil.GetLongitude(feature.Location));
+ feature.Name, feature.Location.GetLatitude(), feature.Location.GetLongitude());
}
else
{
Log("Found no feature at {0}, {1}",
- RouteGuideUtil.GetLatitude(feature.Location),
- RouteGuideUtil.GetLongitude(feature.Location));
+ feature.Location.GetLatitude(), feature.Location.GetLongitude());
}
}
catch (RpcException e)
{
Log("RPC failed " + e);
- throw e;
+ throw;
}
}
@@ -65,18 +62,20 @@ namespace examples
Log("*** ListFeatures: lowLat={0} lowLon={1} hiLat={2} hiLon={3}", lowLat, lowLon, hiLat,
hiLon);
- Rectangle request =
- Rectangle.CreateBuilder()
- .SetLo(Point.CreateBuilder().SetLatitude(lowLat).SetLongitude(lowLon).Build())
- .SetHi(Point.CreateBuilder().SetLatitude(hiLat).SetLongitude(hiLon).Build()).Build();
+ Rectangle request = new Rectangle
+ {
+ Lo = new Point { Latitude = lowLat, Longitude = lowLon },
+ Hi = new Point { Latitude = hiLat, Longitude = hiLon }
+ };
using (var call = client.ListFeatures(request))
{
+ var responseStream = call.ResponseStream;
StringBuilder responseLog = new StringBuilder("Result: ");
- while (await call.ResponseStream.MoveNext())
+ while (await responseStream.MoveNext())
{
- Feature feature = call.ResponseStream.Current;
+ Feature feature = responseStream.Current;
responseLog.Append(feature.ToString());
}
Log(responseLog.ToString());
@@ -85,7 +84,7 @@ namespace examples
catch (RpcException e)
{
Log("RPC failed " + e);
- throw e;
+ throw;
}
}
@@ -107,8 +106,7 @@ namespace examples
{
int index = rand.Next(features.Count);
Point point = features[index].Location;
- Log("Visiting point {0}, {1}", RouteGuideUtil.GetLatitude(point),
- RouteGuideUtil.GetLongitude(point));
+ Log("Visiting point {0}, {1}", point.GetLatitude(), point.GetLongitude());
await call.RequestStream.WriteAsync(point);
@@ -117,7 +115,7 @@ namespace examples
}
await call.RequestStream.CompleteAsync();
- RouteSummary summary = await call.Result;
+ RouteSummary summary = await call.ResponseAsync;
Log("Finished trip with {0} points. Passed {1} features. "
+ "Travelled {2} meters. It took {3} seconds.", summary.PointCount,
summary.FeatureCount, summary.Distance, summary.ElapsedTime);
@@ -128,7 +126,7 @@ namespace examples
catch (RpcException e)
{
Log("RPC failed", e);
- throw e;
+ throw;
}
}
@@ -141,8 +139,13 @@ namespace examples
try
{
Log("*** RouteChat");
- var requests =
- new List<RouteNote> { NewNote("First message", 0, 0), NewNote("Second message", 0, 1), NewNote("Third message", 1, 0), NewNote("Fourth message", 1, 1) };
+ var requests = new List<RouteNote>
+ {
+ NewNote("First message", 0, 0),
+ NewNote("Second message", 0, 1),
+ NewNote("Third message", 1, 0),
+ NewNote("Fourth message", 0, 0)
+ };
using (var call = client.RouteChat())
{
@@ -172,7 +175,7 @@ namespace examples
catch (RpcException e)
{
Log("RPC failed", e);
- throw e;
+ throw;
}
}
@@ -188,36 +191,37 @@ namespace examples
private RouteNote NewNote(string message, int lat, int lon)
{
- return RouteNote.CreateBuilder().SetMessage(message).SetLocation(
- Point.CreateBuilder().SetLatitude(lat).SetLongitude(lat).Build()).Build();
+ return new RouteNote
+ {
+ Message = message,
+ Location = new Point { Latitude = lat, Longitude = lon }
+ };
}
}
static void Main(string[] args)
{
- GrpcEnvironment.Initialize();
+ var channel = new Channel("127.0.0.1:50052", Credentials.Insecure);
+ var client = new RouteGuideClient(RouteGuide.NewClient(channel));
- using (Channel channel = new Channel("127.0.0.1:50052"))
- {
- var client = new RouteGuideClient(RouteGuide.NewStub(channel));
-
- // Looking for a valid feature
- client.GetFeature(409146138, -746188906);
+ // Looking for a valid feature
+ client.GetFeature(409146138, -746188906);
- // Feature missing.
- client.GetFeature(0, 0);
+ // Feature missing.
+ client.GetFeature(0, 0);
- // Looking for features between 40, -75 and 42, -73.
- client.ListFeatures(400000000, -750000000, 420000000, -730000000).Wait();
+ // Looking for features between 40, -75 and 42, -73.
+ client.ListFeatures(400000000, -750000000, 420000000, -730000000).Wait();
- // Record a few randomly selected points from the features file.
- client.RecordRoute(RouteGuideUtil.ParseFeatures(RouteGuideUtil.DefaultFeaturesFile), 10).Wait();
+ // Record a few randomly selected points from the features file.
+ client.RecordRoute(RouteGuideUtil.ParseFeatures(RouteGuideUtil.DefaultFeaturesFile), 10).Wait();
- // Send and receive some notes.
- client.RouteChat().Wait();
- }
+ // Send and receive some notes.
+ client.RouteChat().Wait();
- GrpcEnvironment.Shutdown();
+ channel.ShutdownAsync().Wait();
+ Console.WriteLine("Press any key to exit...");
+ Console.ReadKey();
}
}
}
diff --git a/examples/csharp/route_guide/RouteGuideClient/RouteGuideClient.csproj b/examples/csharp/route_guide/RouteGuideClient/RouteGuideClient.csproj
index 78034a9145..cf9e567f5e 100644
--- a/examples/csharp/route_guide/RouteGuideClient/RouteGuideClient.csproj
+++ b/examples/csharp/route_guide/RouteGuideClient/RouteGuideClient.csproj
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.props" Condition="Exists('..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.props')" />
- <Import Project="..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.props" Condition="Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.props')" />
+ <Import Project="..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props" Condition="Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props')" />
+ <Import Project="..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props" Condition="Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props')" />
<Import Project="..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.props" Condition="Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
@@ -14,7 +14,7 @@
<AssemblyName>RouteGuideClient</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
- <NuGetPackageImportStamp>794416d0</NuGetPackageImportStamp>
+ <NuGetPackageImportStamp>77622de6</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
@@ -36,21 +36,14 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
- <Reference Include="Google.ProtocolBuffers">
- <HintPath>..\packages\Google.ProtocolBuffers.2.4.1.555\lib\net40\Google.ProtocolBuffers.dll</HintPath>
+ <Reference Include="Google.Protobuf">
+ <HintPath>..\packages\Google.Protobuf.3.0.0-alpha4\lib\portable-net45+netcore45+wpa81+wp8\Google.Protobuf.dll</HintPath>
</Reference>
- <Reference Include="Google.ProtocolBuffers.Serialization">
- <HintPath>..\packages\Google.ProtocolBuffers.2.4.1.555\lib\net40\Google.ProtocolBuffers.Serialization.dll</HintPath>
- </Reference>
- <Reference Include="Grpc.Core, Version=0.6.5668.37363, Culture=neutral, processorArchitecture=MSIL">
+ <Reference Include="Grpc.Core, Version=0.7.0.0, Culture=neutral, PublicKeyToken=d754f35622e28bad, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\Grpc.Core.0.6.0\lib\net45\Grpc.Core.dll</HintPath>
+ <HintPath>..\packages\Grpc.Core.0.7.0\lib\net45\Grpc.Core.dll</HintPath>
</Reference>
<Reference Include="System" />
- <Reference Include="System.Collections.Immutable, Version=1.1.36.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\System.Collections.Immutable.1.1.36\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll</HintPath>
- </Reference>
<Reference Include="System.Core" />
<Reference Include="System.Interactive.Async">
<HintPath>..\packages\Ix-Async.1.2.3\lib\net45\System.Interactive.Async.dll</HintPath>
@@ -82,14 +75,14 @@
</PropertyGroup>
<Error Condition="!Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.props'))" />
<Error Condition="!Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets'))" />
- <Error Condition="!Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.props'))" />
- <Error Condition="!Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.targets'))" />
- <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.props'))" />
- <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.targets'))" />
+ <Error Condition="!Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props'))" />
+ <Error Condition="!Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets'))" />
+ <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props'))" />
+ <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets'))" />
</Target>
<Import Project="..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets" Condition="Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets')" />
- <Import Project="..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.targets" Condition="Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.targets')" />
- <Import Project="..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.targets" Condition="Exists('..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.targets')" />
+ <Import Project="..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets" Condition="Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets')" />
+ <Import Project="..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets" Condition="Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
diff --git a/examples/csharp/route_guide/RouteGuideClient/packages.config b/examples/csharp/route_guide/RouteGuideClient/packages.config
index 5922553bc3..1273624cbd 100644
--- a/examples/csharp/route_guide/RouteGuideClient/packages.config
+++ b/examples/csharp/route_guide/RouteGuideClient/packages.config
@@ -1,11 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
- <package id="Google.ProtocolBuffers" version="2.4.1.555" targetFramework="net45" />
- <package id="Grpc" version="0.6.0" targetFramework="net45" />
- <package id="Grpc.Core" version="0.6.0" targetFramework="net45" />
- <package id="grpc.dependencies.openssl.redist" version="1.0.2.2" targetFramework="net45" />
+ <package id="Google.Protobuf" version="3.0.0-alpha4" targetFramework="net45" />
+ <package id="Grpc" version="0.7.0" targetFramework="net45" />
+ <package id="Grpc.Core" version="0.7.0" targetFramework="net45" />
+ <package id="grpc.dependencies.openssl.redist" version="1.0.2.3" targetFramework="net45" />
<package id="grpc.dependencies.zlib.redist" version="1.2.8.9" targetFramework="net45" />
- <package id="grpc.native.csharp_ext" version="0.10.0" targetFramework="net45" />
+ <package id="grpc.native.csharp_ext" version="0.11.0" targetFramework="net45" />
<package id="Ix-Async" version="1.2.3" targetFramework="net45" />
- <package id="System.Collections.Immutable" version="1.1.36" targetFramework="net45" />
</packages> \ No newline at end of file
diff --git a/examples/csharp/route_guide/RouteGuideServer/Program.cs b/examples/csharp/route_guide/RouteGuideServer/Program.cs
index e00b4d6723..0a4d73f391 100644
--- a/examples/csharp/route_guide/RouteGuideServer/Program.cs
+++ b/examples/csharp/route_guide/RouteGuideServer/Program.cs
@@ -5,26 +5,28 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
-namespace examples
+namespace Examples
{
class Program
{
static void Main(string[] args)
{
+ const int Port = 50052;
+
var features = RouteGuideUtil.ParseFeatures(RouteGuideUtil.DefaultFeaturesFile);
- GrpcEnvironment.Initialize();
- Server server = new Server();
- server.AddServiceDefinition(RouteGuide.BindService(new RouteGuideImpl(features)));
- int port = server.AddListeningPort("localhost", 50052);
+ Server server = new Server
+ {
+ Services = { RouteGuide.BindService(new RouteGuideImpl(features)) },
+ Ports = { new ServerPort("localhost", Port, ServerCredentials.Insecure) }
+ };
server.Start();
- Console.WriteLine("RouteGuide server listening on port " + port);
+ Console.WriteLine("RouteGuide server listening on port " + Port);
Console.WriteLine("Press any key to stop the server...");
Console.ReadKey();
server.ShutdownAsync().Wait();
- GrpcEnvironment.Shutdown();
}
}
}
diff --git a/examples/csharp/route_guide/RouteGuideServer/RouteGuideImpl.cs b/examples/csharp/route_guide/RouteGuideServer/RouteGuideImpl.cs
index 0bdf386fc3..fbe0f4471c 100644
--- a/examples/csharp/route_guide/RouteGuideServer/RouteGuideImpl.cs
+++ b/examples/csharp/route_guide/RouteGuideServer/RouteGuideImpl.cs
@@ -6,7 +6,9 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
-namespace examples
+using Grpc.Core.Utils;
+
+namespace Examples
{
/// <summary>
/// Example implementation of RouteGuide server.
@@ -14,8 +16,8 @@ namespace examples
public class RouteGuideImpl : RouteGuide.IRouteGuide
{
readonly List<Feature> features;
- private readonly ConcurrentDictionary<Point, List<RouteNote>> routeNotes =
- new ConcurrentDictionary<Point, List<RouteNote>>();
+ readonly object myLock = new object();
+ readonly Dictionary<Point, List<RouteNote>> routeNotes = new Dictionary<Point, List<RouteNote>>();
public RouteGuideImpl(List<Feature> features)
{
@@ -26,7 +28,7 @@ namespace examples
/// Gets the feature at the requested point. If no feature at that location
/// exists, an unnammed feature is returned at the provided location.
/// </summary>
- public Task<Feature> GetFeature(Grpc.Core.ServerCallContext context, Point request)
+ public Task<Feature> GetFeature(Point request, Grpc.Core.ServerCallContext context)
{
return Task.FromResult(CheckFeature(request));
}
@@ -34,26 +36,12 @@ namespace examples
/// <summary>
/// Gets all features contained within the given bounding rectangle.
/// </summary>
- public async Task ListFeatures(Grpc.Core.ServerCallContext context, Rectangle request, Grpc.Core.IServerStreamWriter<Feature> responseStream)
+ public async Task ListFeatures(Rectangle request, Grpc.Core.IServerStreamWriter<Feature> responseStream, Grpc.Core.ServerCallContext context)
{
- int left = Math.Min(request.Lo.Longitude, request.Hi.Longitude);
- int right = Math.Max(request.Lo.Longitude, request.Hi.Longitude);
- int top = Math.Max(request.Lo.Latitude, request.Hi.Latitude);
- int bottom = Math.Min(request.Lo.Latitude, request.Hi.Latitude);
-
- foreach (var feature in features)
+ var responses = features.FindAll( (feature) => feature.Exists() && request.Contains(feature.Location) );
+ foreach (var response in responses)
{
- if (!RouteGuideUtil.Exists(feature))
- {
- continue;
- }
-
- int lat = feature.Location.Latitude;
- int lon = feature.Location.Longitude;
- if (lon >= left && lon <= right && lat >= bottom && lat <= top)
- {
- await responseStream.WriteAsync(feature);
- }
+ await responseStream.WriteAsync(response);
}
}
@@ -61,7 +49,7 @@ namespace examples
/// Gets a stream of points, and responds with statistics about the "trip": number of points,
/// number of known features visited, total distance traveled, and total time spent.
/// </summary>
- public async Task<RouteSummary> RecordRoute(Grpc.Core.ServerCallContext context, Grpc.Core.IAsyncStreamReader<Point> requestStream)
+ public async Task<RouteSummary> RecordRoute(Grpc.Core.IAsyncStreamReader<Point> requestStream, Grpc.Core.ServerCallContext context)
{
int pointCount = 0;
int featureCount = 0;
@@ -74,61 +62,61 @@ namespace examples
{
var point = requestStream.Current;
pointCount++;
- if (RouteGuideUtil.Exists(CheckFeature(point)))
+ if (CheckFeature(point).Exists())
{
featureCount++;
}
if (previous != null)
{
- distance += (int) CalcDistance(previous, point);
+ distance += (int) previous.GetDistance(point);
}
previous = point;
}
stopwatch.Stop();
- return RouteSummary.CreateBuilder().SetPointCount(pointCount)
- .SetFeatureCount(featureCount).SetDistance(distance)
- .SetElapsedTime((int) (stopwatch.ElapsedMilliseconds / 1000)).Build();
+
+ return new RouteSummary
+ {
+ PointCount = pointCount,
+ FeatureCount = featureCount,
+ Distance = distance,
+ ElapsedTime = (int)(stopwatch.ElapsedMilliseconds / 1000)
+ };
}
/// <summary>
/// Receives a stream of message/location pairs, and responds with a stream of all previous
/// messages at each of those locations.
/// </summary>
- public async Task RouteChat(Grpc.Core.ServerCallContext context, Grpc.Core.IAsyncStreamReader<RouteNote> requestStream, Grpc.Core.IServerStreamWriter<RouteNote> responseStream)
+ public async Task RouteChat(Grpc.Core.IAsyncStreamReader<RouteNote> requestStream, Grpc.Core.IServerStreamWriter<RouteNote> responseStream, Grpc.Core.ServerCallContext context)
{
while (await requestStream.MoveNext())
{
var note = requestStream.Current;
- List<RouteNote> notes = GetOrCreateNotes(note.Location);
-
- List<RouteNote> prevNotes;
- lock (notes)
- {
- prevNotes = new List<RouteNote>(notes);
- }
-
+ List<RouteNote> prevNotes = AddNoteForLocation(note.Location, note);
foreach (var prevNote in prevNotes)
{
await responseStream.WriteAsync(prevNote);
- }
-
- lock (notes)
- {
- notes.Add(note);
}
}
}
-
/// <summary>
- /// Get the notes list for the given location. If missing, create it.
+ /// Adds a note for location and returns a list of pre-existing notes for that location (not containing the newly added note).
/// </summary>
- private List<RouteNote> GetOrCreateNotes(Point location)
+ private List<RouteNote> AddNoteForLocation(Point location, RouteNote note)
{
- List<RouteNote> notes = new List<RouteNote>();
- routeNotes.TryAdd(location, notes);
- return routeNotes[location];
+ lock (myLock)
+ {
+ List<RouteNote> notes;
+ if (!routeNotes.TryGetValue(location, out notes)) {
+ notes = new List<RouteNote>();
+ routeNotes.Add(location, notes);
+ }
+ var preexistingNotes = new List<RouteNote>(notes);
+ notes.Add(note);
+ return preexistingNotes;
+ }
}
/// <summary>
@@ -138,47 +126,13 @@ namespace examples
/// <returns>The feature object at the point Note that an empty name indicates no feature.</returns>
private Feature CheckFeature(Point location)
{
- foreach (var feature in features)
+ var result = features.FirstOrDefault((feature) => feature.Location.Equals(location));
+ if (result == null)
{
- if (feature.Location.Latitude == location.Latitude
- && feature.Location.Longitude == location.Longitude)
- {
- return feature;
- }
+ // No feature was found, return an unnamed feature.
+ return new Feature { Name = "", Location = location };
}
-
- // No feature was found, return an unnamed feature.
- return Feature.CreateBuilder().SetName("").SetLocation(location).Build();
- }
-
- /// <summary>
- /// Calculate the distance between two points using the "haversine" formula.
- /// This code was taken from http://www.movable-type.co.uk/scripts/latlong.html.
- /// </summary>
- /// <param name="start">the starting point</param>
- /// <param name="end">the end point</param>
- /// <returns>the distance between the points in meters</returns>
- private static double CalcDistance(Point start, Point end)
- {
- double lat1 = RouteGuideUtil.GetLatitude(start);
- double lat2 = RouteGuideUtil.GetLatitude(end);
- double lon1 = RouteGuideUtil.GetLongitude(start);
- double lon2 = RouteGuideUtil.GetLongitude(end);
- int r = 6371000; // metres
- double φ1 = ToRadians(lat1);
- double φ2 = ToRadians(lat2);
- double Δφ = ToRadians(lat2 - lat1);
- double Δλ = ToRadians(lon2 - lon1);
-
- double a = Math.Sin(Δφ / 2) * Math.Sin(Δφ / 2) + Math.Cos(φ1) * Math.Cos(φ2) * Math.Sin(Δλ / 2) * Math.Sin(Δλ / 2);
- double c = 2 * Math.Atan2(Math.Sqrt(a), Math.Sqrt(1 - a));
-
- return r * c;
- }
-
- private static double ToRadians(double val)
- {
- return (Math.PI / 180) * val;
+ return result;
}
}
}
diff --git a/examples/csharp/route_guide/RouteGuideServer/RouteGuideServer.csproj b/examples/csharp/route_guide/RouteGuideServer/RouteGuideServer.csproj
index 9ac1cfbf4d..55e1331c46 100644
--- a/examples/csharp/route_guide/RouteGuideServer/RouteGuideServer.csproj
+++ b/examples/csharp/route_guide/RouteGuideServer/RouteGuideServer.csproj
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.props" Condition="Exists('..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.props')" />
- <Import Project="..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.props" Condition="Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.props')" />
+ <Import Project="..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props" Condition="Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props')" />
+ <Import Project="..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props" Condition="Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props')" />
<Import Project="..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.props" Condition="Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
@@ -14,7 +14,7 @@
<AssemblyName>RouteGuideServer</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
- <NuGetPackageImportStamp>74781d8b</NuGetPackageImportStamp>
+ <NuGetPackageImportStamp>568005e2</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
@@ -36,21 +36,14 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
- <Reference Include="Google.ProtocolBuffers">
- <HintPath>..\packages\Google.ProtocolBuffers.2.4.1.555\lib\net40\Google.ProtocolBuffers.dll</HintPath>
+ <Reference Include="Google.Protobuf">
+ <HintPath>..\packages\Google.Protobuf.3.0.0-alpha4\lib\portable-net45+netcore45+wpa81+wp8\Google.Protobuf.dll</HintPath>
</Reference>
- <Reference Include="Google.ProtocolBuffers.Serialization">
- <HintPath>..\packages\Google.ProtocolBuffers.2.4.1.555\lib\net40\Google.ProtocolBuffers.Serialization.dll</HintPath>
- </Reference>
- <Reference Include="Grpc.Core, Version=0.6.5668.37363, Culture=neutral, processorArchitecture=MSIL">
+ <Reference Include="Grpc.Core, Version=0.7.0.0, Culture=neutral, PublicKeyToken=d754f35622e28bad, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\Grpc.Core.0.6.0\lib\net45\Grpc.Core.dll</HintPath>
+ <HintPath>..\packages\Grpc.Core.0.7.0\lib\net45\Grpc.Core.dll</HintPath>
</Reference>
<Reference Include="System" />
- <Reference Include="System.Collections.Immutable, Version=1.1.36.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\System.Collections.Immutable.1.1.36\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll</HintPath>
- </Reference>
<Reference Include="System.Core" />
<Reference Include="System.Interactive.Async">
<HintPath>..\packages\Ix-Async.1.2.3\lib\net45\System.Interactive.Async.dll</HintPath>
@@ -83,14 +76,14 @@
</PropertyGroup>
<Error Condition="!Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.props'))" />
<Error Condition="!Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets'))" />
- <Error Condition="!Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.props'))" />
- <Error Condition="!Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.targets'))" />
- <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.props'))" />
- <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.targets'))" />
+ <Error Condition="!Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props'))" />
+ <Error Condition="!Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets'))" />
+ <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props'))" />
+ <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets'))" />
</Target>
<Import Project="..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets" Condition="Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets')" />
- <Import Project="..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.targets" Condition="Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.targets')" />
- <Import Project="..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.targets" Condition="Exists('..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.targets')" />
+ <Import Project="..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets" Condition="Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets')" />
+ <Import Project="..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets" Condition="Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
diff --git a/examples/csharp/route_guide/RouteGuideServer/packages.config b/examples/csharp/route_guide/RouteGuideServer/packages.config
index 5922553bc3..1273624cbd 100644
--- a/examples/csharp/route_guide/RouteGuideServer/packages.config
+++ b/examples/csharp/route_guide/RouteGuideServer/packages.config
@@ -1,11 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
- <package id="Google.ProtocolBuffers" version="2.4.1.555" targetFramework="net45" />
- <package id="Grpc" version="0.6.0" targetFramework="net45" />
- <package id="Grpc.Core" version="0.6.0" targetFramework="net45" />
- <package id="grpc.dependencies.openssl.redist" version="1.0.2.2" targetFramework="net45" />
+ <package id="Google.Protobuf" version="3.0.0-alpha4" targetFramework="net45" />
+ <package id="Grpc" version="0.7.0" targetFramework="net45" />
+ <package id="Grpc.Core" version="0.7.0" targetFramework="net45" />
+ <package id="grpc.dependencies.openssl.redist" version="1.0.2.3" targetFramework="net45" />
<package id="grpc.dependencies.zlib.redist" version="1.2.8.9" targetFramework="net45" />
- <package id="grpc.native.csharp_ext" version="0.10.0" targetFramework="net45" />
+ <package id="grpc.native.csharp_ext" version="0.11.0" targetFramework="net45" />
<package id="Ix-Async" version="1.2.3" targetFramework="net45" />
- <package id="System.Collections.Immutable" version="1.1.36" targetFramework="net45" />
</packages> \ No newline at end of file
diff --git a/examples/csharp/route_guide/generate_protos.bat b/examples/csharp/route_guide/generate_protos.bat
new file mode 100644
index 0000000000..fb0dc5516b
--- /dev/null
+++ b/examples/csharp/route_guide/generate_protos.bat
@@ -0,0 +1,10 @@
+@rem Generate the C# code for .proto files
+
+setlocal
+
+@rem enter this directory
+cd /d %~dp0
+
+packages\Google.Protobuf.3.0.0-alpha4\tools\protoc.exe -I../../protos --csharp_out RouteGuide ../../protos/route_guide.proto --grpc_out RouteGuide --plugin=protoc-gen-grpc=packages\Grpc.Tools.0.7.0\tools\grpc_csharp_plugin.exe
+
+endlocal \ No newline at end of file
diff --git a/examples/node/route_guide/README.md b/examples/node/route_guide/README.md
index 1dbaac9f9f..1048606509 100644
--- a/examples/node/route_guide/README.md
+++ b/examples/node/route_guide/README.md
@@ -96,10 +96,10 @@ To load a `.proto` file, simply `require` the gRPC library, then use its `load()
var grpc = require('grpc');
var protoDescriptor = grpc.load(__dirname + '/route_guide.proto');
// The protoDescriptor object has the full package hierarchy
-var example = protoDescriptor.examples;
+var example = protoDescriptor.routeguide;
```
-Once you've done this, the stub constructor is in the `examples` namespace (`protoDescriptor.examples.RouteGuide`) and the service descriptor (which is used to create a server) is a property of the stub (`protoDescriptor.examples.RouteGuide.service`);
+Once you've done this, the stub constructor is in the `routeguide` namespace (`protoDescriptor.routeguide.RouteGuide`) and the service descriptor (which is used to create a server) is a property of the stub (`protoDescriptor.routeguide.RouteGuide.service`);
<a name="server"></a>
## Creating the server
@@ -117,7 +117,7 @@ You can find our example `RouteGuide` server in [route_guide_server.js](route_gu
As you can see, our server has a `Server` constructor generated from the `RouteGuide.service` descriptor object
```node
-var Server = grpc.buildServer([examples.RouteGuide.service]);
+var Server = grpc.buildServer([routeguide.RouteGuide.service]);
```
In this case we're implementing the *asynchronous* version of `RouteGuide`, which provides our default gRPC server behaviour.
@@ -219,18 +219,18 @@ Once we've implemented all our methods, we also need to start up a gRPC server s
```node
function getServer() {
- return new Server({
- 'examples.RouteGuide' : {
- getFeature: getFeature,
- listFeatures: listFeatures,
- recordRoute: recordRoute,
- routeChat: routeChat
- }
+ var server = new grpc.Server();
+ server.addProtoService(routeguide.RouteGuide.service, {
+ getFeature: getFeature,
+ listFeatures: listFeatures,
+ recordRoute: recordRoute,
+ routeChat: routeChat
});
+ return server;
}
var routeServer = getServer();
-routeServer.bind('0.0.0.0:50051');
-routeServer.listen();
+routeServer.bind('0.0.0.0:50051', grpc.ServerCredentials.createInsecure());
+routeServer.start();
```
As you can see, we build and start our server with the following steps:
@@ -251,7 +251,8 @@ In this section, we'll look at creating a Node.js client for our `RouteGuide` se
To call service methods, we first need to create a *stub*. To do this, we just need to call the RouteGuide stub constructor, specifying the server address and port.
```node
-new example.RouteGuide('localhost:50051');
+var client = new routeguide.RouteGuide('localhost:50051',
+ grpc.Credentials.createInsecure());
```
### Calling service methods
diff --git a/examples/node/route_guide/route_guide.proto b/examples/node/route_guide/route_guide.proto
index 442112823e..38daa933cd 100644
--- a/examples/node/route_guide/route_guide.proto
+++ b/examples/node/route_guide/route_guide.proto
@@ -29,9 +29,9 @@
syntax = "proto3";
-option java_package = "io.grpc.examples";
+option java_package = "io.grpc.routeguide";
-package examples;
+package routeguide;
// Interface exported by the server.
service RouteGuide {
diff --git a/examples/node/route_guide/route_guide_client.js b/examples/node/route_guide/route_guide_client.js
index 3550d797d9..1da6c69025 100644
--- a/examples/node/route_guide/route_guide_client.js
+++ b/examples/node/route_guide/route_guide_client.js
@@ -33,9 +33,9 @@ var parseArgs = require('minimist');
var path = require('path');
var _ = require('underscore');
var grpc = require('grpc');
-var examples = grpc.load(__dirname + '/route_guide.proto').examples;
-var client = new examples.RouteGuide('localhost:50051',
- grpc.Credentials.createInsecure());
+var routeguide = grpc.load(__dirname + '/route_guide.proto').routeguide;
+var client = new routeguide.RouteGuide('localhost:50051',
+ grpc.Credentials.createInsecure());
var COORD_FACTOR = 1e7;
diff --git a/examples/node/route_guide/route_guide_server.js b/examples/node/route_guide/route_guide_server.js
index 38e1f94a92..faae3087fd 100644
--- a/examples/node/route_guide/route_guide_server.js
+++ b/examples/node/route_guide/route_guide_server.js
@@ -32,7 +32,7 @@ var parseArgs = require('minimist');
var path = require('path');
var _ = require('underscore');
var grpc = require('grpc');
-var examples = grpc.load(__dirname + '/route_guide.proto').examples;
+var routeguide = grpc.load(__dirname + '/route_guide.proto').routeguide;
var COORD_FACTOR = 1e7;
@@ -221,7 +221,7 @@ function routeChat(call) {
*/
function getServer() {
var server = new grpc.Server();
- server.addProtoService(examples.RouteGuide.service, {
+ server.addProtoService(routeguide.RouteGuide.service, {
getFeature: getFeature,
listFeatures: listFeatures,
recordRoute: recordRoute,