| Index: third_party/grpc/examples/csharp/helloworld/GreeterServer/Program.cs
|
| diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/RepeatedFieldAccessor.cs b/third_party/grpc/examples/csharp/helloworld/GreeterServer/Program.cs
|
| similarity index 61%
|
| copy from third_party/protobuf/csharp/src/Google.Protobuf/Reflection/RepeatedFieldAccessor.cs
|
| copy to third_party/grpc/examples/csharp/helloworld/GreeterServer/Program.cs
|
| index bd408470929bf250b7f0104f34209198dc0fda63..79f421df9e1f4743a2ad5930a8218e51019f6f47 100644
|
| --- a/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/RepeatedFieldAccessor.cs
|
| +++ b/third_party/grpc/examples/csharp/helloworld/GreeterServer/Program.cs
|
| @@ -1,7 +1,5 @@
|
| -#region Copyright notice and license
|
| -// Protocol Buffers - Google's data interchange format
|
| -// Copyright 2015 Google Inc. All rights reserved.
|
| -// https://developers.google.com/protocol-buffers/
|
| +// 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
|
| @@ -28,33 +26,41 @@
|
| // 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.
|
| -#endregion
|
|
|
| using System;
|
| -using System.Collections;
|
| -using System.Reflection;
|
| +using System.Threading.Tasks;
|
| +using Grpc.Core;
|
| +using Helloworld;
|
|
|
| -namespace Google.Protobuf.Reflection
|
| +namespace GreeterServer
|
| {
|
| - /// <summary>
|
| - /// Accessor for repeated fields.
|
| - /// </summary>
|
| - internal sealed class RepeatedFieldAccessor : FieldAccessorBase
|
| + class GreeterImpl : Greeter.IGreeter
|
| {
|
| - internal RepeatedFieldAccessor(PropertyInfo property, FieldDescriptor descriptor) : base(property, descriptor)
|
| + // Server side handler of the SayHello RPC
|
| + public Task<HelloReply> SayHello(HelloRequest request, ServerCallContext context)
|
| {
|
| + return Task.FromResult(new HelloReply { Message = "Hello " + request.Name });
|
| }
|
| + }
|
|
|
| - public override void Clear(IMessage message)
|
| - {
|
| - IList list = (IList) GetValue(message);
|
| - list.Clear();
|
| - }
|
| + class Program
|
| + {
|
| + const int Port = 50051;
|
|
|
| - public override void SetValue(IMessage message, object value)
|
| + public static void Main(string[] args)
|
| {
|
| - throw new InvalidOperationException("SetValue is not implemented for repeated fields");
|
| - }
|
| + 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();
|
| + }
|
| }
|
| }
|
|
|