├── class ├── dummy.proto ├── client │ ├── App.config │ ├── packages.config │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Program.cs │ └── client.csproj ├── server │ ├── App.config │ ├── packages.config │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Program.cs │ ├── GreetingServiceImpl.cs │ └── server.csproj ├── greeting.proto ├── ssl │ └── ssl.sh └── grpc-csharp-class.sln ├── exercises ├── sum-unary-api │ ├── client │ │ ├── App.config │ │ ├── packages.config │ │ ├── Program.cs │ │ ├── Properties │ │ │ └── AssemblyInfo.cs │ │ └── client.csproj │ ├── server │ │ ├── App.config │ │ ├── CalculatorServiceImpl.cs │ │ ├── packages.config │ │ ├── Program.cs │ │ ├── Properties │ │ │ └── AssemblyInfo.cs │ │ └── server.csproj │ ├── calculator.proto │ └── sum-unary-api.sln ├── prime-number-decomposition │ ├── client │ │ ├── App.config │ │ ├── packages.config │ │ ├── Program.cs │ │ ├── Properties │ │ │ └── AssemblyInfo.cs │ │ └── client.csproj │ ├── server │ │ ├── App.config │ │ ├── packages.config │ │ ├── PrimeNumberServiceImpl.cs │ │ ├── Program.cs │ │ ├── Properties │ │ │ └── AssemblyInfo.cs │ │ └── server.csproj │ ├── prime.proto │ └── prime-number-decomposition.sln ├── find_maximum │ ├── max.proto │ ├── client │ │ ├── client.csproj │ │ └── Program.cs │ ├── server │ │ ├── server.csproj │ │ ├── FindMaxServiceImpl.cs │ │ └── Program.cs │ └── find_maximum.sln └── compute-average │ ├── average.proto │ ├── client │ ├── client.csproj │ ├── Program.cs │ └── models │ │ ├── AverageGrpc.cs │ │ └── Average.cs │ ├── server │ ├── server.csproj │ ├── AverageServiceImpl.cs │ ├── Program.cs │ └── models │ │ ├── AverageGrpc.cs │ │ └── Average.cs │ └── compute-average.sln ├── README.md ├── advanced ├── sqrt │ ├── sqrt.proto │ ├── server │ │ ├── SqrtServiceImpl.cs │ │ ├── server.csproj │ │ └── Program.cs │ ├── client │ │ ├── client.csproj │ │ └── Program.cs │ └── sqrt.sln └── great_with_deadline │ ├── greeting.proto │ ├── server │ ├── GreetingServiceImpl.cs │ ├── server.csproj │ └── Program.cs │ ├── client │ ├── client.csproj │ └── Program.cs │ ├── ssl │ └── ssl.sh │ └── great_with_deadline.sln ├── blog ├── client │ ├── client.csproj │ └── Program.cs ├── server │ ├── server.csproj │ ├── Program.cs │ └── BlogServiceImpl.cs ├── blog.proto └── grpc-blog.sln └── .gitignore /class/dummy.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package dummy; 4 | 5 | message DummyMessage {} 6 | 7 | service DummyService {} -------------------------------------------------------------------------------- /class/client/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /exercises/sum-unary-api/client/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /exercises/sum-unary-api/server/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /exercises/prime-number-decomposition/client/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /exercises/prime-number-decomposition/server/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # gRPC C# 2 | 3 | ## COUPON: `START_OCT_2025` 4 | 5 | ## Reminder 6 | 7 | - In order to run SSL features, do not forget to run the shell script 8 | - If you find any missing or uncorrect code, please report an issue. 9 | - Feel free to make pull requests ! 10 | -------------------------------------------------------------------------------- /advanced/sqrt/sqrt.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package sqrt; 4 | 5 | message SqrtRequest { 6 | int32 number = 1; 7 | } 8 | 9 | message SqrtReponse { 10 | double square_root = 1; 11 | } 12 | 13 | service SqrtService { 14 | rpc sqrt (SqrtRequest) returns (SqrtReponse) {} 15 | } -------------------------------------------------------------------------------- /exercises/sum-unary-api/calculator.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package calculator; 4 | 5 | message SumRequest { 6 | int32 a = 1; 7 | int32 b = 2; 8 | } 9 | 10 | message SumResponse { 11 | int32 result = 1; 12 | } 13 | 14 | service CalculatorService { 15 | rpc Sum(SumRequest) returns (SumResponse) {} 16 | } -------------------------------------------------------------------------------- /exercises/find_maximum/max.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package max; 4 | 5 | message FindMaxRequest { 6 | int32 number = 1; 7 | } 8 | 9 | message FindMaxResponse { 10 | int32 max = 1; 11 | } 12 | 13 | service FindMaxService { 14 | rpc findMaximum (stream FindMaxRequest) returns (stream FindMaxResponse) {} 15 | } -------------------------------------------------------------------------------- /exercises/compute-average/average.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package average; 4 | 5 | message AverageRequest { 6 | int32 number = 1; 7 | } 8 | 9 | message AverageResponse { 10 | double result = 1; 11 | } 12 | 13 | service AverageService { 14 | rpc ComputeAverage (stream AverageRequest) returns (AverageResponse) {} 15 | } -------------------------------------------------------------------------------- /advanced/great_with_deadline/greeting.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package greeting; 4 | 5 | message GreetingRequest { 6 | string name = 1; 7 | } 8 | 9 | message Greetingresponse { 10 | string result = 1; 11 | } 12 | 13 | service GreetingService { 14 | rpc greet_with_deadline (GreetingRequest) returns (Greetingresponse) {} 15 | } -------------------------------------------------------------------------------- /exercises/prime-number-decomposition/prime.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package prime; 4 | 5 | message PrimeNumberDecompositionRequest { 6 | int32 number = 1; 7 | } 8 | 9 | message PrimeNumberDecompositionResponse { 10 | int32 prime_factor = 1; 11 | } 12 | 13 | service PrimeNumberService { 14 | rpc PrimeNumberDecomposition (PrimeNumberDecompositionRequest) returns (stream PrimeNumberDecompositionResponse) {} 15 | } -------------------------------------------------------------------------------- /class/server/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /advanced/great_with_deadline/server/GreetingServiceImpl.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Threading.Tasks; 5 | using Greeting; 6 | using Grpc.Core; 7 | using static Greeting.GreetingService; 8 | 9 | namespace server 10 | { 11 | public class GreetingServiceImpl : GreetingServiceBase 12 | { 13 | public override async Task greet_with_deadline(GreetingRequest request, ServerCallContext context) 14 | { 15 | await Task.Delay(300); 16 | 17 | return new Greetingresponse() { Result = "Hello " + request.Name }; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /exercises/sum-unary-api/server/CalculatorServiceImpl.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Calculator; 7 | using Grpc.Core; 8 | using static Calculator.CalculatorService; 9 | 10 | namespace server 11 | { 12 | public class CalculatorServiceImpl : CalculatorServiceBase 13 | { 14 | public override Task Sum(SumRequest request, ServerCallContext context) 15 | { 16 | int result = request.A + request.B; 17 | 18 | return Task.FromResult(new SumResponse() { Result = result }); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /advanced/sqrt/server/SqrtServiceImpl.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Threading.Tasks; 5 | using Grpc.Core; 6 | using Sqrt; 7 | using static Sqrt.SqrtService; 8 | 9 | namespace server 10 | { 11 | public class SqrtServiceImpl : SqrtServiceBase 12 | { 13 | public override async Task sqrt(SqrtRequest request, ServerCallContext context) 14 | { 15 | await Task.Delay(1500); 16 | 17 | int number = request.Number; 18 | 19 | if (number >= 0) 20 | return new SqrtReponse() { SquareRoot = Math.Sqrt(number) }; 21 | else 22 | throw new RpcException(new Status(StatusCode.InvalidArgument, "number < 0")); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /class/client/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /blog/client/client.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | all 17 | runtime; build; native; contentfiles; analyzers; buildtransitive 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /exercises/sum-unary-api/client/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /exercises/sum-unary-api/server/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /advanced/sqrt/client/client.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | all 13 | runtime; build; native; contentfiles; analyzers; buildtransitive 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /advanced/sqrt/server/server.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | all 13 | runtime; build; native; contentfiles; analyzers; buildtransitive 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /exercises/find_maximum/client/client.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | all 13 | runtime; build; native; contentfiles; analyzers; buildtransitive 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /exercises/find_maximum/server/server.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | all 13 | runtime; build; native; contentfiles; analyzers; buildtransitive 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /exercises/prime-number-decomposition/client/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /exercises/prime-number-decomposition/server/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /exercises/compute-average/client/client.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | all 13 | runtime; build; native; contentfiles; analyzers; buildtransitive 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /exercises/compute-average/server/server.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | all 13 | runtime; build; native; contentfiles; analyzers; buildtransitive 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /exercises/compute-average/server/AverageServiceImpl.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Threading.Tasks; 5 | using Average; 6 | using Grpc.Core; 7 | using static Average.AverageService; 8 | 9 | namespace server 10 | { 11 | public class AverageServiceImpl : AverageServiceBase 12 | { 13 | public override async Task ComputeAverage(IAsyncStreamReader requestStream, ServerCallContext context) 14 | { 15 | int total = 0; 16 | double result = 0.0; 17 | 18 | while (await requestStream.MoveNext()) 19 | { 20 | result += requestStream.Current.Number; 21 | total++; 22 | } 23 | 24 | return new AverageResponse() { Result = result / total }; 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /class/server/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /exercises/find_maximum/server/FindMaxServiceImpl.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Threading.Tasks; 5 | using Grpc.Core; 6 | using Max; 7 | using static Max.FindMaxService; 8 | 9 | namespace server 10 | { 11 | public class FindMaxServiceImpl : FindMaxServiceBase 12 | { 13 | public override async Task findMaximum(IAsyncStreamReader requestStream, IServerStreamWriter responseStream, ServerCallContext context) 14 | { 15 | int? max = null; 16 | 17 | while (await requestStream.MoveNext()) 18 | { 19 | if (max == null || max < requestStream.Current.Number) 20 | { 21 | max = requestStream.Current.Number; 22 | await responseStream.WriteAsync(new FindMaxResponse() { Max = max.Value }); 23 | } 24 | } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /blog/server/server.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | all 18 | runtime; build; native; contentfiles; analyzers; buildtransitive 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /advanced/sqrt/server/Program.cs: -------------------------------------------------------------------------------- 1 | using Grpc.Core; 2 | using Sqrt; 3 | using System; 4 | using System.IO; 5 | 6 | namespace server 7 | { 8 | class Program 9 | { 10 | const int Port = 50052; 11 | 12 | static void Main(string[] args) 13 | { 14 | Server server = null; 15 | 16 | try 17 | { 18 | server = new Server() 19 | { 20 | Services = { SqrtService.BindService(new SqrtServiceImpl()) }, 21 | Ports = { new ServerPort("localhost", Port, ServerCredentials.Insecure) } 22 | }; 23 | 24 | server.Start(); 25 | Console.WriteLine("The server is listening on the port : " + Port); 26 | Console.ReadKey(); 27 | } 28 | catch (IOException e) 29 | { 30 | Console.WriteLine("The server failed to start : " + e.Message); 31 | throw; 32 | } 33 | finally 34 | { 35 | if (server != null) 36 | server.ShutdownAsync().Wait(); 37 | } 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /exercises/find_maximum/server/Program.cs: -------------------------------------------------------------------------------- 1 | using Grpc.Core; 2 | using Max; 3 | using System; 4 | using System.IO; 5 | 6 | namespace server 7 | { 8 | class Program 9 | { 10 | const int Port = 50052; 11 | 12 | static void Main(string[] args) 13 | { 14 | Server server = null; 15 | 16 | try 17 | { 18 | server = new Server() 19 | { 20 | Services = { FindMaxService.BindService(new FindMaxServiceImpl()) }, 21 | Ports = { new ServerPort("localhost", Port, ServerCredentials.Insecure) } 22 | }; 23 | 24 | server.Start(); 25 | Console.WriteLine("The server is listening on the port : " + Port); 26 | Console.ReadKey(); 27 | } 28 | catch (IOException e) 29 | { 30 | Console.WriteLine("The server failed to start : " + e.Message); 31 | throw; 32 | } 33 | finally 34 | { 35 | if (server != null) 36 | server.ShutdownAsync().Wait(); 37 | } 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /exercises/compute-average/server/Program.cs: -------------------------------------------------------------------------------- 1 | using Average; 2 | using Grpc.Core; 3 | using System; 4 | using System.IO; 5 | 6 | namespace server 7 | { 8 | class Program 9 | { 10 | const int Port = 50052; 11 | 12 | static void Main(string[] args) 13 | { 14 | Server server = null; 15 | 16 | try 17 | { 18 | server = new Server() 19 | { 20 | Services = { AverageService.BindService(new AverageServiceImpl()) }, 21 | Ports = { new ServerPort("localhost", Port, ServerCredentials.Insecure) } 22 | }; 23 | 24 | server.Start(); 25 | Console.WriteLine("The server is listening on the port : " + Port); 26 | Console.ReadKey(); 27 | } 28 | catch (IOException e) 29 | { 30 | Console.WriteLine("The server failed to start : " + e.Message); 31 | throw; 32 | } 33 | finally 34 | { 35 | if (server != null) 36 | server.ShutdownAsync().Wait(); 37 | } 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /exercises/sum-unary-api/client/Program.cs: -------------------------------------------------------------------------------- 1 | using Calculator; 2 | using Grpc.Core; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace client 10 | { 11 | class Program 12 | { 13 | const string target = "127.0.0.1:50052"; 14 | 15 | static void Main(string[] args) 16 | { 17 | Channel channel = new Channel(target, ChannelCredentials.Insecure); 18 | 19 | channel.ConnectAsync().ContinueWith((task) => 20 | { 21 | if (task.Status == TaskStatus.RanToCompletion) 22 | Console.WriteLine("The client connected successfully"); 23 | }); 24 | 25 | var client = new CalculatorService.CalculatorServiceClient(channel); 26 | 27 | var request = new SumRequest() 28 | { 29 | A = 3, 30 | B = 10 31 | }; 32 | 33 | var response = client.Sum(request); 34 | 35 | Console.WriteLine(response.Result); 36 | 37 | channel.ShutdownAsync().Wait(); 38 | Console.ReadKey(); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /class/greeting.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package greet; 4 | 5 | message Greeting { 6 | string first_name = 1; 7 | string last_name = 2; 8 | } 9 | 10 | message GreetingRequest { 11 | Greeting greeting = 1; 12 | } 13 | 14 | message GreetingResponse { 15 | string result = 1; 16 | } 17 | 18 | message GreetManyTimesRequest { 19 | Greeting greeting = 1; 20 | } 21 | 22 | message GreetManyTimesResponse { 23 | string result = 1; 24 | } 25 | 26 | message LongGreetRequest { 27 | Greeting greeting = 1; 28 | } 29 | 30 | message LongGreetResponse { 31 | string result = 1; 32 | } 33 | 34 | message GreetEveryoneRequest { 35 | Greeting greeting = 1; 36 | } 37 | 38 | message GreetEveryoneResponse { 39 | string result = 1; 40 | } 41 | 42 | service GreetingService { 43 | // Unary 44 | rpc Greet (GreetingRequest) returns (GreetingResponse) {} 45 | 46 | // Server streaming 47 | rpc GreetManyTimes (GreetManyTimesRequest) returns (stream GreetManyTimesResponse) {} 48 | 49 | // Client streaming 50 | rpc LongGreet (stream LongGreetRequest) returns (LongGreetResponse) {} 51 | 52 | // Bidi streaming 53 | rpc GreetEveryone (stream GreetEveryoneRequest) returns (stream GreetEveryoneResponse) {} 54 | } -------------------------------------------------------------------------------- /exercises/prime-number-decomposition/server/PrimeNumberServiceImpl.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Grpc.Core; 7 | using Prime; 8 | using static Prime.PrimeNumberService; 9 | 10 | namespace server 11 | { 12 | public class PrimeNumberServiceImpl : PrimeNumberServiceBase 13 | { 14 | public override async Task PrimeNumberDecomposition(PrimeNumberDecompositionRequest request, IServerStreamWriter responseStream, ServerCallContext context) 15 | { 16 | Console.WriteLine("The server received the request :"); 17 | Console.WriteLine(request.ToString()); 18 | 19 | int number = request.Number; 20 | int divisor = 2; 21 | 22 | while (number > 1) 23 | { 24 | if (number % divisor == 0) 25 | { 26 | number /= divisor; 27 | await responseStream.WriteAsync(new PrimeNumberDecompositionResponse() { PrimeFactor = divisor }); 28 | } 29 | else 30 | divisor++; 31 | } 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /blog/blog.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package blog; 4 | 5 | message Blog { 6 | string id = 1; 7 | string author_id = 2; 8 | string title = 3; 9 | string content = 4; 10 | } 11 | 12 | message CreateBlogRequest { 13 | Blog blog = 1; // will not contain an id 14 | } 15 | 16 | message CreateBlogResponse { 17 | Blog blog = 1; // will contain an id 18 | } 19 | 20 | message ReadBlogRequest { 21 | string blog_id = 1; 22 | } 23 | 24 | message ReadBlogResponse { 25 | Blog blog = 1; 26 | } 27 | 28 | message UpdateBlogRequest { 29 | Blog blog = 1; 30 | } 31 | 32 | message UpdateBlogResponse { 33 | Blog blog = 1; 34 | } 35 | 36 | message DeleteBlogRequest { 37 | string blog_id = 1; 38 | } 39 | 40 | message DeleteBlogRepsponse { 41 | string blog_id = 1; 42 | } 43 | 44 | message ListBlogRequest { 45 | 46 | } 47 | 48 | message ListBlogResponse { 49 | Blog blog = 1; 50 | } 51 | 52 | service BlogService { 53 | rpc CreateBlog (CreateBlogRequest) returns (CreateBlogResponse) {} 54 | rpc ReadBlog (ReadBlogRequest) returns (ReadBlogResponse) {} 55 | rpc UpdateBlog (UpdateBlogRequest) returns (UpdateBlogResponse) {} 56 | rpc DeleteBlog (DeleteBlogRequest) returns (DeleteBlogRepsponse) {} 57 | rpc ListBlog (ListBlogRequest) returns (stream ListBlogResponse) {} 58 | } -------------------------------------------------------------------------------- /exercises/sum-unary-api/server/Program.cs: -------------------------------------------------------------------------------- 1 | using Calculator; 2 | using Grpc.Core; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.IO; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | 10 | namespace server 11 | { 12 | class Program 13 | { 14 | const int Port = 50052; 15 | 16 | static void Main(string[] args) 17 | { 18 | Server server = null; 19 | 20 | try 21 | { 22 | server = new Server() 23 | { 24 | Services = { CalculatorService.BindService(new CalculatorServiceImpl()) }, 25 | Ports = { new ServerPort("localhost", Port, ServerCredentials.Insecure) } 26 | }; 27 | 28 | server.Start(); 29 | Console.WriteLine("The server is listening on the port : " + Port); 30 | Console.ReadKey(); 31 | } 32 | catch (IOException e) 33 | { 34 | Console.WriteLine("The server failed to start : " + e.Message); 35 | throw; 36 | } 37 | finally 38 | { 39 | if (server != null) 40 | server.ShutdownAsync().Wait(); 41 | } 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /exercises/prime-number-decomposition/server/Program.cs: -------------------------------------------------------------------------------- 1 | using Grpc.Core; 2 | using Prime; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.IO; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | 10 | namespace server 11 | { 12 | class Program 13 | { 14 | const int Port = 50052; 15 | 16 | static async Task Main(string[] args) 17 | { 18 | Server server = null; 19 | 20 | try 21 | { 22 | server = new Server() 23 | { 24 | Services = { PrimeNumberService.BindService(new PrimeNumberServiceImpl()) }, 25 | Ports = { new ServerPort("localhost", Port, ServerCredentials.Insecure) } 26 | }; 27 | 28 | server.Start(); 29 | Console.WriteLine("The server is listening on the port : " + Port); 30 | Console.ReadKey(); 31 | } 32 | catch (IOException e) 33 | { 34 | Console.WriteLine("The server failed to start : " + e.Message); 35 | throw; 36 | } 37 | finally 38 | { 39 | if (server != null) 40 | server.ShutdownAsync().Wait(); 41 | } 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /exercises/compute-average/client/Program.cs: -------------------------------------------------------------------------------- 1 | using Average; 2 | using Grpc.Core; 3 | using System; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | 7 | namespace client 8 | { 9 | class Program 10 | { 11 | const string target = "127.0.0.1:50052"; 12 | 13 | static async Task Main(string[] args) 14 | { 15 | Channel channel = new Channel(target, ChannelCredentials.Insecure); 16 | 17 | await channel.ConnectAsync().ContinueWith((task) => 18 | { 19 | if (task.Status == TaskStatus.RanToCompletion) 20 | Console.WriteLine("The client connected successfully"); 21 | }); 22 | 23 | var client = new AverageService.AverageServiceClient(channel); 24 | var stream = client.ComputeAverage(); 25 | 26 | foreach (int number in Enumerable.Range(1, 4)) 27 | { 28 | var request = new AverageRequest() { Number = number }; 29 | 30 | await stream.RequestStream.WriteAsync(request); 31 | } 32 | 33 | await stream.RequestStream.CompleteAsync(); 34 | 35 | var response = await stream.ResponseAsync; 36 | 37 | Console.WriteLine(response.Result); 38 | 39 | channel.ShutdownAsync().Wait(); 40 | Console.ReadKey(); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /exercises/prime-number-decomposition/client/Program.cs: -------------------------------------------------------------------------------- 1 | using Grpc.Core; 2 | using Prime; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace client 10 | { 11 | class Program 12 | { 13 | const string target = "127.0.0.1:50052"; 14 | 15 | static async Task Main(string[] args) 16 | { 17 | Channel channel = new Channel(target, ChannelCredentials.Insecure); 18 | 19 | await channel.ConnectAsync().ContinueWith((task) => 20 | { 21 | if (task.Status == TaskStatus.RanToCompletion) 22 | Console.WriteLine("The client connected successfully"); 23 | }); 24 | 25 | var client = new PrimeNumberService.PrimeNumberServiceClient(channel); 26 | 27 | var request = new PrimeNumberDecompositionRequest() 28 | { 29 | Number = 120 30 | }; 31 | 32 | var response = client.PrimeNumberDecomposition(request); 33 | 34 | while (await response.ResponseStream.MoveNext()) 35 | { 36 | Console.WriteLine(response.ResponseStream.Current.PrimeFactor); 37 | await Task.Delay(200); 38 | } 39 | 40 | channel.ShutdownAsync().Wait(); 41 | Console.ReadKey(); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /advanced/great_with_deadline/server/server.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | all 13 | runtime; build; native; contentfiles; analyzers; buildtransitive 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | PreserveNewest 30 | 31 | 32 | PreserveNewest 33 | 34 | 35 | PreserveNewest 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /blog/server/Program.cs: -------------------------------------------------------------------------------- 1 | using Blog; 2 | using Grpc.Core; 3 | using Grpc.Reflection; 4 | using Grpc.Reflection.V1Alpha; 5 | using System; 6 | using System.IO; 7 | 8 | namespace server 9 | { 10 | class Program 11 | { 12 | const int Port = 50052; 13 | 14 | static void Main(string[] args) 15 | { 16 | Server server = null; 17 | 18 | try 19 | { 20 | var reflectionServiceImpl = new ReflectionServiceImpl(BlogService.Descriptor, ServerReflection.Descriptor); 21 | 22 | server = new Server() 23 | { 24 | Services = { 25 | BlogService.BindService(new BlogServiceImpl()), 26 | ServerReflection.BindService(reflectionServiceImpl) 27 | }, 28 | Ports = { new ServerPort("localhost", Port, ServerCredentials.Insecure) } 29 | }; 30 | 31 | server.Start(); 32 | Console.WriteLine("The server is listening on the port : " + Port); 33 | Console.ReadKey(); 34 | } 35 | catch (IOException e) 36 | { 37 | Console.WriteLine("The server failed to start : " + e.Message); 38 | throw; 39 | } 40 | finally 41 | { 42 | if (server != null) 43 | server.ShutdownAsync().Wait(); 44 | } 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /advanced/great_with_deadline/client/client.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | all 13 | runtime; build; native; contentfiles; analyzers; buildtransitive 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | PreserveNewest 30 | 31 | 32 | PreserveNewest 33 | 34 | 35 | PreserveNewest 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /exercises/find_maximum/client/Program.cs: -------------------------------------------------------------------------------- 1 | using Grpc.Core; 2 | using Max; 3 | using System; 4 | using System.IO; 5 | using System.Threading.Tasks; 6 | 7 | namespace client 8 | { 9 | class Program 10 | { 11 | const string target = "127.0.0.1:50052"; 12 | 13 | static async Task Main(string[] args) 14 | { 15 | Channel channel = new Channel(target, ChannelCredentials.Insecure); 16 | 17 | await channel.ConnectAsync().ContinueWith((task) => 18 | { 19 | if (task.Status == TaskStatus.RanToCompletion) 20 | Console.WriteLine("The client connected successfully"); 21 | }); 22 | 23 | var client = new FindMaxService.FindMaxServiceClient(channel); 24 | var stream = client.findMaximum(); 25 | 26 | var responseReaderTask = Task.Run(async () => 27 | { 28 | while (await stream.ResponseStream.MoveNext()) 29 | Console.WriteLine(stream.ResponseStream.Current.Max); 30 | }); 31 | 32 | int[] numbers = { 1, 5, 3, 6, 2, 20 }; 33 | 34 | foreach (var number in numbers) 35 | { 36 | await stream.RequestStream.WriteAsync(new FindMaxRequest() { Number = number }); 37 | } 38 | 39 | await stream.RequestStream.CompleteAsync(); 40 | await responseReaderTask; 41 | 42 | channel.ShutdownAsync().Wait(); 43 | Console.ReadKey(); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /class/client/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("client")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("client")] 13 | [assembly: AssemblyCopyright("Copyright © 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("b43dea46-171b-4397-b9da-2d16cd029ce2")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /class/server/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("server")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("server")] 13 | [assembly: AssemblyCopyright("Copyright © 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("f101cbd9-e27e-4d1b-9a20-6b2e404714c8")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /advanced/sqrt/client/Program.cs: -------------------------------------------------------------------------------- 1 | using Grpc.Core; 2 | using Sqrt; 3 | using System; 4 | using System.Threading.Tasks; 5 | 6 | namespace client 7 | { 8 | class Program 9 | { 10 | const string target = "127.0.0.1:50052"; 11 | 12 | static async Task Main(string[] args) 13 | { 14 | Channel channel = new Channel(target, ChannelCredentials.Insecure); 15 | 16 | await channel.ConnectAsync().ContinueWith((task) => 17 | { 18 | if (task.Status == TaskStatus.RanToCompletion) 19 | Console.WriteLine("The client connected successfully"); 20 | }); 21 | 22 | var client = new SqrtService.SqrtServiceClient(channel); 23 | int number = 16; 24 | 25 | try 26 | { 27 | var response = client.sqrt(new SqrtRequest() { Number = number }, 28 | deadline: DateTime.UtcNow.AddSeconds(1)); 29 | 30 | Console.WriteLine(response.SquareRoot); 31 | } 32 | catch (RpcException e) when (e.StatusCode == StatusCode.InvalidArgument) 33 | { 34 | Console.WriteLine("Error : " + e.Status.Detail); 35 | } 36 | catch (RpcException e) when (e.StatusCode == StatusCode.DeadlineExceeded) 37 | { 38 | Console.WriteLine("Deadline exceeded !"); 39 | } 40 | 41 | channel.ShutdownAsync().Wait(); 42 | Console.ReadKey(); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /exercises/sum-unary-api/client/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("client")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("client")] 13 | [assembly: AssemblyCopyright("Copyright © 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("bab76262-3b4d-4e1e-ac0a-c31874976c99")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /exercises/sum-unary-api/server/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("server")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("server")] 13 | [assembly: AssemblyCopyright("Copyright © 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("2dd46579-e85a-4455-827c-248de906b148")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /exercises/prime-number-decomposition/client/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("client")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("client")] 13 | [assembly: AssemblyCopyright("Copyright © 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("087d7603-09d3-4b26-a5fb-5ac2b205c3f8")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /exercises/prime-number-decomposition/server/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("server")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("server")] 13 | [assembly: AssemblyCopyright("Copyright © 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("e60ddda0-f6b0-4188-9315-18a325b7020d")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /advanced/great_with_deadline/server/Program.cs: -------------------------------------------------------------------------------- 1 | using Greeting; 2 | using Grpc.Core; 3 | using Grpc.Core.Logging; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.IO; 7 | using System.Reflection; 8 | 9 | namespace server 10 | { 11 | class Program 12 | { 13 | const int Port = 50051; 14 | 15 | static void Main(string[] args) 16 | { 17 | Server server = null; 18 | 19 | try 20 | { 21 | var keypair = new KeyCertificatePair(File.ReadAllText("ssl/server.crt"), File.ReadAllText("ssl/server.key")); 22 | var cacert = File.ReadAllText("ssl/ca.crt"); 23 | var credentials = new SslServerCredentials(new List() { keypair }, cacert, false); 24 | 25 | server = new Server() 26 | { 27 | Services = { GreetingService.BindService(new GreetingServiceImpl()) }, 28 | Ports = { new ServerPort("localhost", Port, credentials) } 29 | }; 30 | 31 | server.Start(); 32 | Console.WriteLine("The server is listening on the port : " + Port); 33 | Console.ReadKey(); 34 | } 35 | catch (IOException e) 36 | { 37 | Console.WriteLine("The server failed to start : " + e.Message); 38 | throw; 39 | } 40 | finally 41 | { 42 | if (server != null) 43 | server.ShutdownAsync().Wait(); 44 | } 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /class/ssl/ssl.sh: -------------------------------------------------------------------------------- 1 | @echo off 2 | SERVER_CN=localhost 3 | set OPENSSL_CONF=c:\OpenSSL-Win64\bin\openssl.cfg 4 | 5 | echo Generate CA key: 6 | openssl genrsa -passout pass:1111 -des3 -out ca.key 4096 7 | 8 | echo Generate CA certificate: 9 | openssl req -passin pass:1111 -new -x509 -days 365 -key ca.key -out ca.crt -subj "//CN=MyRootCA" 10 | 11 | echo Generate server key: 12 | openssl genrsa -passout pass:1111 -des3 -out server.key 4096 13 | 14 | echo Generate server signing request: 15 | openssl req -passin pass:1111 -new -key server.key -out server.csr -subj "//CN=${SERVER_CN}" 16 | 17 | echo Self-sign server certificate: 18 | openssl x509 -req -passin pass:1111 -days 365 -in server.csr -CA ca.crt -CAkey ca.key -set_serial 01 -out server.crt 19 | 20 | echo Remove passphrase from server key: 21 | openssl rsa -passin pass:1111 -in server.key -out server.key 22 | 23 | echo Generate client key 24 | openssl genrsa -passout pass:1111 -des3 -out client.key 4096 25 | 26 | echo Generate client signing request: 27 | openssl req -passin pass:1111 -new -key client.key -out client.csr -subj "//CN=${SERVER_CN}" 28 | 29 | echo Self-sign client certificate: 30 | openssl x509 -passin pass:1111 -req -days 365 -in client.csr -CA ca.crt -CAkey ca.key -set_serial 01 -out client.crt 31 | 32 | echo Remove passphrase from client key: 33 | openssl rsa -passin pass:1111 -in client.key -out client.key 34 | 35 | cp ca.crt ../server/ssl/ca.crt 36 | cp ca.crt ../client/ssl/ca.crt 37 | 38 | mv server.crt ../server/ssl/server.crt 39 | mv server.key ../server/ssl/server.key 40 | 41 | mv client.crt ../client/ssl/client.crt 42 | mv client.key ../client/ssl/client.key -------------------------------------------------------------------------------- /advanced/great_with_deadline/ssl/ssl.sh: -------------------------------------------------------------------------------- 1 | @echo off 2 | SERVER_CN=localhost 3 | set OPENSSL_CONF=c:\OpenSSL-Win64\bin\openssl.cfg 4 | 5 | echo Generate CA key: 6 | openssl genrsa -passout pass:1111 -des3 -out ca.key 4096 7 | 8 | echo Generate CA certificate: 9 | openssl req -passin pass:1111 -new -x509 -days 365 -key ca.key -out ca.crt -subj "//CN=MyRootCA" 10 | 11 | echo Generate server key: 12 | openssl genrsa -passout pass:1111 -des3 -out server.key 4096 13 | 14 | echo Generate server signing request: 15 | openssl req -passin pass:1111 -new -key server.key -out server.csr -subj "//CN=${SERVER_CN}" 16 | 17 | echo Self-sign server certificate: 18 | openssl x509 -req -passin pass:1111 -days 365 -in server.csr -CA ca.crt -CAkey ca.key -set_serial 01 -out server.crt 19 | 20 | echo Remove passphrase from server key: 21 | openssl rsa -passin pass:1111 -in server.key -out server.key 22 | 23 | echo Generate client key 24 | openssl genrsa -passout pass:1111 -des3 -out client.key 4096 25 | 26 | echo Generate client signing request: 27 | openssl req -passin pass:1111 -new -key client.key -out client.csr -subj "//CN=${SERVER_CN}" 28 | 29 | echo Self-sign client certificate: 30 | openssl x509 -passin pass:1111 -req -days 365 -in client.csr -CA ca.crt -CAkey ca.key -set_serial 01 -out client.crt 31 | 32 | echo Remove passphrase from client key: 33 | openssl rsa -passin pass:1111 -in client.key -out client.key 34 | 35 | cp ca.crt ../server/ssl/ca.crt 36 | cp ca.crt ../client/ssl/ca.crt 37 | 38 | cp server.crt ../server/ssl/server.crt 39 | cp server.key ../server/ssl/server.key 40 | 41 | cp client.crt ../client/ssl/client.crt 42 | cp client.key ../client/ssl/client.key -------------------------------------------------------------------------------- /advanced/great_with_deadline/client/Program.cs: -------------------------------------------------------------------------------- 1 | using Greeting; 2 | using Grpc.Core; 3 | using Grpc.Core.Logging; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.IO; 7 | using System.Threading.Tasks; 8 | 9 | namespace client 10 | { 11 | class Program 12 | { 13 | const string target = "127.0.0.1:50051"; 14 | 15 | static async Task Main(string[] args) 16 | { 17 | var clientcert = File.ReadAllText("ssl/client.crt"); 18 | var clientkey = File.ReadAllText("ssl/client.key"); 19 | var cacert = File.ReadAllText("ssl/ca.crt"); 20 | var channelCredentials = new SslCredentials(cacert, new KeyCertificatePair(clientcert, clientkey)); 21 | Channel channel = new Channel("localhost", 50051, channelCredentials); 22 | 23 | await channel.ConnectAsync().ContinueWith((task) => 24 | { 25 | if (task.Status == TaskStatus.RanToCompletion) 26 | Console.WriteLine("The client connected successfully"); 27 | }); 28 | 29 | var client = new GreetingService.GreetingServiceClient(channel); 30 | 31 | try 32 | { 33 | var response = client.greet_with_deadline(new GreetingRequest() { Name = "John" }, 34 | deadline: DateTime.UtcNow.AddSeconds(1)); 35 | 36 | Console.WriteLine(response.Result); 37 | } 38 | catch (RpcException e) when (e.StatusCode == StatusCode.DeadlineExceeded) 39 | { 40 | Console.WriteLine("Error : " + e.Status.Detail); 41 | } 42 | 43 | channel.ShutdownAsync().Wait(); 44 | Console.ReadKey(); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /blog/grpc-blog.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.29424.173 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "client", "client\client.csproj", "{5E028208-9CF1-4E08-B7AB-F59A41C1A2C7}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "server", "server\server.csproj", "{950BEE2F-555C-4377-95C0-3A3D432C156F}" 9 | EndProject 10 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "proto", "proto", "{E32C338F-FE02-4683-964F-F7ADEE94BE98}" 11 | ProjectSection(SolutionItems) = preProject 12 | blog.proto = blog.proto 13 | EndProjectSection 14 | EndProject 15 | Global 16 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 17 | Debug|Any CPU = Debug|Any CPU 18 | Release|Any CPU = Release|Any CPU 19 | EndGlobalSection 20 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 21 | {5E028208-9CF1-4E08-B7AB-F59A41C1A2C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 22 | {5E028208-9CF1-4E08-B7AB-F59A41C1A2C7}.Debug|Any CPU.Build.0 = Debug|Any CPU 23 | {5E028208-9CF1-4E08-B7AB-F59A41C1A2C7}.Release|Any CPU.ActiveCfg = Release|Any CPU 24 | {5E028208-9CF1-4E08-B7AB-F59A41C1A2C7}.Release|Any CPU.Build.0 = Release|Any CPU 25 | {950BEE2F-555C-4377-95C0-3A3D432C156F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 26 | {950BEE2F-555C-4377-95C0-3A3D432C156F}.Debug|Any CPU.Build.0 = Debug|Any CPU 27 | {950BEE2F-555C-4377-95C0-3A3D432C156F}.Release|Any CPU.ActiveCfg = Release|Any CPU 28 | {950BEE2F-555C-4377-95C0-3A3D432C156F}.Release|Any CPU.Build.0 = Release|Any CPU 29 | EndGlobalSection 30 | GlobalSection(SolutionProperties) = preSolution 31 | HideSolutionNode = FALSE 32 | EndGlobalSection 33 | GlobalSection(ExtensibilityGlobals) = postSolution 34 | SolutionGuid = {4C29B29A-C44B-46D2-B728-1B9FB874BDFF} 35 | EndGlobalSection 36 | EndGlobal 37 | -------------------------------------------------------------------------------- /advanced/sqrt/sqrt.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.29424.173 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "proto", "proto", "{8EBDE407-FE0E-4700-8152-F877DB9ACCAD}" 7 | ProjectSection(SolutionItems) = preProject 8 | sqrt.proto = sqrt.proto 9 | EndProjectSection 10 | EndProject 11 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "client", "client\client.csproj", "{FE8F952F-2899-46B8-BF33-A428E812DE17}" 12 | EndProject 13 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "server", "server\server.csproj", "{954D222D-1A07-48D2-BDE2-AB41236D966C}" 14 | EndProject 15 | Global 16 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 17 | Debug|Any CPU = Debug|Any CPU 18 | Release|Any CPU = Release|Any CPU 19 | EndGlobalSection 20 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 21 | {FE8F952F-2899-46B8-BF33-A428E812DE17}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 22 | {FE8F952F-2899-46B8-BF33-A428E812DE17}.Debug|Any CPU.Build.0 = Debug|Any CPU 23 | {FE8F952F-2899-46B8-BF33-A428E812DE17}.Release|Any CPU.ActiveCfg = Release|Any CPU 24 | {FE8F952F-2899-46B8-BF33-A428E812DE17}.Release|Any CPU.Build.0 = Release|Any CPU 25 | {954D222D-1A07-48D2-BDE2-AB41236D966C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 26 | {954D222D-1A07-48D2-BDE2-AB41236D966C}.Debug|Any CPU.Build.0 = Debug|Any CPU 27 | {954D222D-1A07-48D2-BDE2-AB41236D966C}.Release|Any CPU.ActiveCfg = Release|Any CPU 28 | {954D222D-1A07-48D2-BDE2-AB41236D966C}.Release|Any CPU.Build.0 = Release|Any CPU 29 | EndGlobalSection 30 | GlobalSection(SolutionProperties) = preSolution 31 | HideSolutionNode = FALSE 32 | EndGlobalSection 33 | GlobalSection(ExtensibilityGlobals) = postSolution 34 | SolutionGuid = {3F574150-D524-48E6-A829-0B41EAB0302E} 35 | EndGlobalSection 36 | EndGlobal 37 | -------------------------------------------------------------------------------- /exercises/find_maximum/find_maximum.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.29424.173 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "proto", "proto", "{A52EA17B-A7FB-4F72-A8CF-7C054EB20CE7}" 7 | ProjectSection(SolutionItems) = preProject 8 | max.proto = max.proto 9 | EndProjectSection 10 | EndProject 11 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "client", "client\client.csproj", "{9A7ED956-38AE-4A85-9467-CC0A36E5B5B9}" 12 | EndProject 13 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "server", "server\server.csproj", "{91D2A2C6-00C1-4F21-B087-38F20D07FE02}" 14 | EndProject 15 | Global 16 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 17 | Debug|Any CPU = Debug|Any CPU 18 | Release|Any CPU = Release|Any CPU 19 | EndGlobalSection 20 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 21 | {9A7ED956-38AE-4A85-9467-CC0A36E5B5B9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 22 | {9A7ED956-38AE-4A85-9467-CC0A36E5B5B9}.Debug|Any CPU.Build.0 = Debug|Any CPU 23 | {9A7ED956-38AE-4A85-9467-CC0A36E5B5B9}.Release|Any CPU.ActiveCfg = Release|Any CPU 24 | {9A7ED956-38AE-4A85-9467-CC0A36E5B5B9}.Release|Any CPU.Build.0 = Release|Any CPU 25 | {91D2A2C6-00C1-4F21-B087-38F20D07FE02}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 26 | {91D2A2C6-00C1-4F21-B087-38F20D07FE02}.Debug|Any CPU.Build.0 = Debug|Any CPU 27 | {91D2A2C6-00C1-4F21-B087-38F20D07FE02}.Release|Any CPU.ActiveCfg = Release|Any CPU 28 | {91D2A2C6-00C1-4F21-B087-38F20D07FE02}.Release|Any CPU.Build.0 = Release|Any CPU 29 | EndGlobalSection 30 | GlobalSection(SolutionProperties) = preSolution 31 | HideSolutionNode = FALSE 32 | EndGlobalSection 33 | GlobalSection(ExtensibilityGlobals) = postSolution 34 | SolutionGuid = {81089C85-88D3-4FA5-81A3-C30301C760EF} 35 | EndGlobalSection 36 | EndGlobal 37 | -------------------------------------------------------------------------------- /exercises/compute-average/compute-average.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.29418.71 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "client", "client\client.csproj", "{C706D710-B55A-41DC-BA85-F798820DC55C}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "server", "server\server.csproj", "{108AE5B8-DB85-43E7-AED0-C69FEDCCEEDF}" 9 | EndProject 10 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "proto", "proto", "{9C5D8D3E-1D24-48BC-8DB4-D83300B8302E}" 11 | ProjectSection(SolutionItems) = preProject 12 | average.proto = average.proto 13 | EndProjectSection 14 | EndProject 15 | Global 16 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 17 | Debug|Any CPU = Debug|Any CPU 18 | Release|Any CPU = Release|Any CPU 19 | EndGlobalSection 20 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 21 | {C706D710-B55A-41DC-BA85-F798820DC55C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 22 | {C706D710-B55A-41DC-BA85-F798820DC55C}.Debug|Any CPU.Build.0 = Debug|Any CPU 23 | {C706D710-B55A-41DC-BA85-F798820DC55C}.Release|Any CPU.ActiveCfg = Release|Any CPU 24 | {C706D710-B55A-41DC-BA85-F798820DC55C}.Release|Any CPU.Build.0 = Release|Any CPU 25 | {108AE5B8-DB85-43E7-AED0-C69FEDCCEEDF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 26 | {108AE5B8-DB85-43E7-AED0-C69FEDCCEEDF}.Debug|Any CPU.Build.0 = Debug|Any CPU 27 | {108AE5B8-DB85-43E7-AED0-C69FEDCCEEDF}.Release|Any CPU.ActiveCfg = Release|Any CPU 28 | {108AE5B8-DB85-43E7-AED0-C69FEDCCEEDF}.Release|Any CPU.Build.0 = Release|Any CPU 29 | EndGlobalSection 30 | GlobalSection(SolutionProperties) = preSolution 31 | HideSolutionNode = FALSE 32 | EndGlobalSection 33 | GlobalSection(ExtensibilityGlobals) = postSolution 34 | SolutionGuid = {2D5BD117-4C0E-48A1-9F5B-C5B9F34116CF} 35 | EndGlobalSection 36 | EndGlobal 37 | -------------------------------------------------------------------------------- /exercises/sum-unary-api/sum-unary-api.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.29411.108 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "proto", "proto", "{AD19FA01-EA39-412D-B0F7-E8CF4E21080B}" 7 | ProjectSection(SolutionItems) = preProject 8 | calculator.proto = calculator.proto 9 | EndProjectSection 10 | EndProject 11 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "client", "client\client.csproj", "{BAB76262-3B4D-4E1E-AC0A-C31874976C99}" 12 | EndProject 13 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "server", "server\server.csproj", "{2DD46579-E85A-4455-827C-248DE906B148}" 14 | EndProject 15 | Global 16 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 17 | Debug|Any CPU = Debug|Any CPU 18 | Release|Any CPU = Release|Any CPU 19 | EndGlobalSection 20 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 21 | {BAB76262-3B4D-4E1E-AC0A-C31874976C99}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 22 | {BAB76262-3B4D-4E1E-AC0A-C31874976C99}.Debug|Any CPU.Build.0 = Debug|Any CPU 23 | {BAB76262-3B4D-4E1E-AC0A-C31874976C99}.Release|Any CPU.ActiveCfg = Release|Any CPU 24 | {BAB76262-3B4D-4E1E-AC0A-C31874976C99}.Release|Any CPU.Build.0 = Release|Any CPU 25 | {2DD46579-E85A-4455-827C-248DE906B148}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 26 | {2DD46579-E85A-4455-827C-248DE906B148}.Debug|Any CPU.Build.0 = Debug|Any CPU 27 | {2DD46579-E85A-4455-827C-248DE906B148}.Release|Any CPU.ActiveCfg = Release|Any CPU 28 | {2DD46579-E85A-4455-827C-248DE906B148}.Release|Any CPU.Build.0 = Release|Any CPU 29 | EndGlobalSection 30 | GlobalSection(SolutionProperties) = preSolution 31 | HideSolutionNode = FALSE 32 | EndGlobalSection 33 | GlobalSection(ExtensibilityGlobals) = postSolution 34 | SolutionGuid = {9A5DA9DD-9124-4642-AB25-6CFCF8040D30} 35 | EndGlobalSection 36 | EndGlobal 37 | -------------------------------------------------------------------------------- /exercises/prime-number-decomposition/prime-number-decomposition.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.29411.108 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "client", "client\client.csproj", "{087D7603-09D3-4B26-A5FB-5AC2B205C3F8}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "server", "server\server.csproj", "{E60DDDA0-F6B0-4188-9315-18A325B7020D}" 9 | EndProject 10 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "proto", "proto", "{BC5D1D55-1FBC-4639-9971-72F86310D42A}" 11 | ProjectSection(SolutionItems) = preProject 12 | prime.proto = prime.proto 13 | EndProjectSection 14 | EndProject 15 | Global 16 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 17 | Debug|Any CPU = Debug|Any CPU 18 | Release|Any CPU = Release|Any CPU 19 | EndGlobalSection 20 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 21 | {087D7603-09D3-4B26-A5FB-5AC2B205C3F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 22 | {087D7603-09D3-4B26-A5FB-5AC2B205C3F8}.Debug|Any CPU.Build.0 = Debug|Any CPU 23 | {087D7603-09D3-4B26-A5FB-5AC2B205C3F8}.Release|Any CPU.ActiveCfg = Release|Any CPU 24 | {087D7603-09D3-4B26-A5FB-5AC2B205C3F8}.Release|Any CPU.Build.0 = Release|Any CPU 25 | {E60DDDA0-F6B0-4188-9315-18A325B7020D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 26 | {E60DDDA0-F6B0-4188-9315-18A325B7020D}.Debug|Any CPU.Build.0 = Debug|Any CPU 27 | {E60DDDA0-F6B0-4188-9315-18A325B7020D}.Release|Any CPU.ActiveCfg = Release|Any CPU 28 | {E60DDDA0-F6B0-4188-9315-18A325B7020D}.Release|Any CPU.Build.0 = Release|Any CPU 29 | EndGlobalSection 30 | GlobalSection(SolutionProperties) = preSolution 31 | HideSolutionNode = FALSE 32 | EndGlobalSection 33 | GlobalSection(ExtensibilityGlobals) = postSolution 34 | SolutionGuid = {7ABA1E1B-EBCF-42B2-A7B5-997ED809B390} 35 | EndGlobalSection 36 | EndGlobal 37 | -------------------------------------------------------------------------------- /class/server/Program.cs: -------------------------------------------------------------------------------- 1 | using Greet; 2 | using Grpc.Core; 3 | using Grpc.Reflection; 4 | using Grpc.Reflection.V1Alpha; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.IO; 8 | using System.Linq; 9 | using System.Text; 10 | using System.Threading.Tasks; 11 | 12 | namespace server 13 | { 14 | class Program 15 | { 16 | const int Port = 50051; 17 | 18 | static void Main(string[] args) 19 | { 20 | Server server = null; 21 | 22 | try 23 | { 24 | //var serverCert = File.ReadAllText("ssl/server.crt"); 25 | //var serverKey = File.ReadAllText("ssl/server.key"); 26 | //var keypair = new KeyCertificatePair(serverCert, serverKey); 27 | //var cacert = File.ReadAllText("ssl/ca.crt"); 28 | 29 | //var credentials = new SslServerCredentials(new List() { keypair }, cacert, true); 30 | 31 | var reflectionServiceImpl = new ReflectionServiceImpl(GreetingService.Descriptor, ServerReflection.Descriptor); 32 | 33 | server = new Server() 34 | { 35 | Services = { 36 | GreetingService.BindService(new GreetingServiceImpl()), 37 | ServerReflection.BindService(reflectionServiceImpl) 38 | }, 39 | Ports = { new ServerPort("localhost", Port, ServerCredentials.Insecure) }// credentials) } 40 | }; 41 | 42 | server.Start(); 43 | Console.WriteLine("The server is listening on the port : " + Port); 44 | Console.ReadKey(); 45 | } 46 | catch (IOException e) 47 | { 48 | Console.WriteLine("The server failed to start : " + e.Message); 49 | throw; 50 | } 51 | finally 52 | { 53 | if (server != null) 54 | server.ShutdownAsync().Wait(); 55 | } 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /advanced/great_with_deadline/great_with_deadline.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.29424.173 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "proto", "proto", "{89BBEC49-C33B-40B4-9ABE-129A6839DA2D}" 7 | ProjectSection(SolutionItems) = preProject 8 | greeting.proto = greeting.proto 9 | EndProjectSection 10 | EndProject 11 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "client", "client\client.csproj", "{CC3B7298-69DE-4F9B-BB39-EE9B9A12C51F}" 12 | EndProject 13 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "server", "server\server.csproj", "{51AF59DA-8554-4113-819C-014E0256D3A5}" 14 | EndProject 15 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{60BFEE64-D752-431A-94C6-1453EA0F0CA4}" 16 | ProjectSection(SolutionItems) = preProject 17 | ssl.sh = ssl.sh 18 | EndProjectSection 19 | EndProject 20 | Global 21 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 22 | Debug|Any CPU = Debug|Any CPU 23 | Release|Any CPU = Release|Any CPU 24 | EndGlobalSection 25 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 26 | {CC3B7298-69DE-4F9B-BB39-EE9B9A12C51F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 27 | {CC3B7298-69DE-4F9B-BB39-EE9B9A12C51F}.Debug|Any CPU.Build.0 = Debug|Any CPU 28 | {CC3B7298-69DE-4F9B-BB39-EE9B9A12C51F}.Release|Any CPU.ActiveCfg = Release|Any CPU 29 | {CC3B7298-69DE-4F9B-BB39-EE9B9A12C51F}.Release|Any CPU.Build.0 = Release|Any CPU 30 | {51AF59DA-8554-4113-819C-014E0256D3A5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 31 | {51AF59DA-8554-4113-819C-014E0256D3A5}.Debug|Any CPU.Build.0 = Debug|Any CPU 32 | {51AF59DA-8554-4113-819C-014E0256D3A5}.Release|Any CPU.ActiveCfg = Release|Any CPU 33 | {51AF59DA-8554-4113-819C-014E0256D3A5}.Release|Any CPU.Build.0 = Release|Any CPU 34 | EndGlobalSection 35 | GlobalSection(SolutionProperties) = preSolution 36 | HideSolutionNode = FALSE 37 | EndGlobalSection 38 | GlobalSection(ExtensibilityGlobals) = postSolution 39 | SolutionGuid = {8B315B5E-C5A6-4875-A554-2D073CEBDACD} 40 | EndGlobalSection 41 | EndGlobal 42 | -------------------------------------------------------------------------------- /class/grpc-csharp-class.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.29403.142 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "proto", "proto", "{337DFA0B-4476-4932-8139-DBEC67097CA7}" 7 | ProjectSection(SolutionItems) = preProject 8 | dummy.proto = dummy.proto 9 | greeting.proto = greeting.proto 10 | EndProjectSection 11 | EndProject 12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "client", "client\client.csproj", "{B43DEA46-171B-4397-B9DA-2D16CD029CE2}" 13 | EndProject 14 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "server", "server\server.csproj", "{F101CBD9-E27E-4D1B-9A20-6B2E404714C8}" 15 | EndProject 16 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{6CE96E76-1491-46E0-B60B-1B6F9A99AC09}" 17 | ProjectSection(SolutionItems) = preProject 18 | ssl\ssl.sh = ssl\ssl.sh 19 | EndProjectSection 20 | EndProject 21 | Global 22 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 23 | Debug|Any CPU = Debug|Any CPU 24 | Release|Any CPU = Release|Any CPU 25 | EndGlobalSection 26 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 27 | {B43DEA46-171B-4397-B9DA-2D16CD029CE2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 28 | {B43DEA46-171B-4397-B9DA-2D16CD029CE2}.Debug|Any CPU.Build.0 = Debug|Any CPU 29 | {B43DEA46-171B-4397-B9DA-2D16CD029CE2}.Release|Any CPU.ActiveCfg = Release|Any CPU 30 | {B43DEA46-171B-4397-B9DA-2D16CD029CE2}.Release|Any CPU.Build.0 = Release|Any CPU 31 | {F101CBD9-E27E-4D1B-9A20-6B2E404714C8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 32 | {F101CBD9-E27E-4D1B-9A20-6B2E404714C8}.Debug|Any CPU.Build.0 = Debug|Any CPU 33 | {F101CBD9-E27E-4D1B-9A20-6B2E404714C8}.Release|Any CPU.ActiveCfg = Release|Any CPU 34 | {F101CBD9-E27E-4D1B-9A20-6B2E404714C8}.Release|Any CPU.Build.0 = Release|Any CPU 35 | EndGlobalSection 36 | GlobalSection(SolutionProperties) = preSolution 37 | HideSolutionNode = FALSE 38 | EndGlobalSection 39 | GlobalSection(ExtensibilityGlobals) = postSolution 40 | SolutionGuid = {87000557-7F49-4854-8E6F-3AD4FCBB142E} 41 | EndGlobalSection 42 | EndGlobal 43 | -------------------------------------------------------------------------------- /class/server/GreetingServiceImpl.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Greet; 7 | using Grpc.Core; 8 | using static Greet.GreetingService; 9 | 10 | namespace server 11 | { 12 | public class GreetingServiceImpl : GreetingServiceBase 13 | { 14 | public override Task Greet(GreetingRequest request, ServerCallContext context) 15 | { 16 | string result = String.Format("hello {0} {1}", request.Greeting.FirstName, request.Greeting.LastName); 17 | 18 | return Task.FromResult(new GreetingResponse() { Result = result }); 19 | } 20 | 21 | public override async Task GreetManyTimes(GreetManyTimesRequest request, IServerStreamWriter responseStream, ServerCallContext context) 22 | { 23 | Console.WriteLine("The server received the request : "); 24 | Console.WriteLine(request.ToString()); 25 | 26 | string result = String.Format("hello {0} {1}", request.Greeting.FirstName, request.Greeting.LastName); 27 | 28 | foreach (int i in Enumerable.Range(1, 10)) 29 | { 30 | await responseStream.WriteAsync(new GreetManyTimesResponse() { Result = result }); 31 | } 32 | } 33 | 34 | public override async Task LongGreet(IAsyncStreamReader requestStream, ServerCallContext context) 35 | { 36 | string result = ""; 37 | 38 | while (await requestStream.MoveNext()) 39 | { 40 | result += String.Format("Hello {0} {1} {2}", 41 | requestStream.Current.Greeting.FirstName, 42 | requestStream.Current.Greeting.LastName, 43 | Environment.NewLine); 44 | } 45 | 46 | return new LongGreetResponse() { Result = result }; 47 | } 48 | 49 | public override async Task GreetEveryone(IAsyncStreamReader requestStream, IServerStreamWriter responseStream, ServerCallContext context) 50 | { 51 | while (await requestStream.MoveNext()) 52 | { 53 | var result = String.Format("Hello {0} {1}", 54 | requestStream.Current.Greeting.FirstName, 55 | requestStream.Current.Greeting.LastName); 56 | 57 | Console.WriteLine("Sending : " + result); 58 | await responseStream.WriteAsync(new GreetEveryoneResponse() { Result = result }); 59 | } 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /blog/client/Program.cs: -------------------------------------------------------------------------------- 1 | using Blog; 2 | using Grpc.Core; 3 | using System; 4 | using System.IO; 5 | using System.Threading.Tasks; 6 | 7 | namespace client 8 | { 9 | class Program 10 | { 11 | static async Task Main(string[] args) 12 | { 13 | Channel channel = new Channel("localhost", 50052, ChannelCredentials.Insecure); 14 | 15 | await channel.ConnectAsync().ContinueWith((task) => 16 | { 17 | if (task.Status == TaskStatus.RanToCompletion) 18 | Console.WriteLine("The client connected successfully"); 19 | }); 20 | 21 | var client = new BlogService.BlogServiceClient(channel); 22 | 23 | //var newBlog = CreateBlog(client); 24 | //ReadBlog(client); 25 | 26 | //UpdateBlog(client, newBlog); 27 | //DeleteBlog(client, newBlog); 28 | 29 | await ListBlog(client); 30 | 31 | channel.ShutdownAsync().Wait(); 32 | Console.ReadKey(); 33 | } 34 | 35 | private static Blog.Blog CreateBlog(BlogService.BlogServiceClient client) 36 | { 37 | var response = client.CreateBlog(new CreateBlogRequest() 38 | { 39 | Blog = new Blog.Blog() 40 | { 41 | AuthorId = "Clement", 42 | Title = "New blog!", 43 | Content = "Hello world, this is a new blog" 44 | } 45 | }); 46 | 47 | Console.WriteLine("The blog " + response.Blog.Id + " was created !"); 48 | 49 | return response.Blog; 50 | } 51 | private static void ReadBlog(BlogService.BlogServiceClient client) 52 | { 53 | try 54 | { 55 | var response = client.ReadBlog(new ReadBlogRequest() 56 | { 57 | BlogId = "5dc06aeb807d5b450456803d" 58 | }); 59 | 60 | Console.WriteLine(response.Blog.ToString()); 61 | } 62 | catch (RpcException e) 63 | { 64 | Console.WriteLine(e.Status.Detail); 65 | } 66 | } 67 | private static void UpdateBlog(BlogService.BlogServiceClient client, Blog.Blog blog) 68 | { 69 | try 70 | { 71 | blog.AuthorId = "Updated author"; 72 | blog.Title = "Updated title"; 73 | blog.Content = "Updated content"; 74 | 75 | var response = client.UpdateBlog(new UpdateBlogRequest() 76 | { 77 | Blog = blog 78 | }); 79 | 80 | Console.WriteLine(response.Blog.ToString()); 81 | } 82 | catch (RpcException e) 83 | { 84 | Console.WriteLine(e.Status.Detail); 85 | } 86 | } 87 | private static void DeleteBlog(BlogService.BlogServiceClient client, Blog.Blog blog) 88 | { 89 | try 90 | { 91 | var response = client.DeleteBlog(new DeleteBlogRequest() { BlogId = blog.Id }); 92 | 93 | Console.WriteLine("The blog with id " + response.BlogId + " was deleted"); 94 | } 95 | catch (RpcException e) 96 | { 97 | Console.WriteLine(e.Status.Detail); 98 | } 99 | } 100 | private static async Task ListBlog(BlogService.BlogServiceClient client) 101 | { 102 | var response = client.ListBlog(new ListBlogRequest() { }); 103 | 104 | while (await response.ResponseStream.MoveNext()) 105 | { 106 | Console.WriteLine(response.ResponseStream.Current.Blog.ToString()); 107 | } 108 | } 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /class/client/Program.cs: -------------------------------------------------------------------------------- 1 | using Dummy; 2 | using Greet; 3 | using Grpc.Core; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.IO; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace client 12 | { 13 | class Program 14 | { 15 | const string target = "127.0.0.1:50051"; 16 | 17 | static async Task Main(string[] args) 18 | { 19 | //var clientCert = File.ReadAllText("ssl/client.crt"); 20 | //var clientKey = File.ReadAllText("ssl/client.key"); 21 | //var caCrt = File.ReadAllText("ssl/ca.crt"); 22 | 23 | //var channelCredentials = new SslCredentials(caCrt, new KeyCertificatePair(clientCert, clientKey)); 24 | 25 | Channel channel = new Channel("localhost", 50051, ChannelCredentials.Insecure);// channelCredentials); 26 | 27 | await channel.ConnectAsync().ContinueWith((task) => 28 | { 29 | if (task.Status == TaskStatus.RanToCompletion) 30 | Console.WriteLine("The client connected successfully"); 31 | }); 32 | 33 | var client = new GreetingService.GreetingServiceClient(channel); 34 | 35 | DoSimpleGreet(client); 36 | //await DoManyGreetings(client); 37 | //await DoLongGreet(client); 38 | //await DoGreetEveryone(client); 39 | 40 | channel.ShutdownAsync().Wait(); 41 | Console.ReadKey(); 42 | } 43 | 44 | public static void DoSimpleGreet(GreetingService.GreetingServiceClient client) 45 | { 46 | var greeting = new Greeting() 47 | { 48 | FirstName = "Clement", 49 | LastName = "Jean" 50 | }; 51 | 52 | var request = new GreetingRequest() { Greeting = greeting }; 53 | var response = client.Greet(request); 54 | 55 | Console.WriteLine(response.Result); 56 | } 57 | public static async Task DoManyGreetings(GreetingService.GreetingServiceClient client) 58 | { 59 | var greeting = new Greeting() 60 | { 61 | FirstName = "Clement", 62 | LastName = "Jean" 63 | }; 64 | 65 | var request = new GreetManyTimesRequest() { Greeting = greeting }; 66 | var response = client.GreetManyTimes(request); 67 | 68 | while (await response.ResponseStream.MoveNext()) 69 | { 70 | Console.WriteLine(response.ResponseStream.Current.Result); 71 | await Task.Delay(200); 72 | } 73 | } 74 | public static async Task DoLongGreet(GreetingService.GreetingServiceClient client) 75 | { 76 | var greeting = new Greeting() 77 | { 78 | FirstName = "Clement", 79 | LastName = "Jean" 80 | }; 81 | 82 | var request = new LongGreetRequest() { Greeting = greeting }; 83 | var stream = client.LongGreet(); 84 | 85 | foreach (int i in Enumerable.Range(1, 10)) 86 | { 87 | await stream.RequestStream.WriteAsync(request); 88 | } 89 | 90 | await stream.RequestStream.CompleteAsync(); 91 | 92 | var response = await stream.ResponseAsync; 93 | 94 | Console.WriteLine(response.Result); 95 | } 96 | public static async Task DoGreetEveryone(GreetingService.GreetingServiceClient client) 97 | { 98 | var stream = client.GreetEveryone(); 99 | 100 | var responseReaderTask = Task.Run(async () => 101 | { 102 | while (await stream.ResponseStream.MoveNext()) 103 | { 104 | Console.WriteLine("Received : " + stream.ResponseStream.Current.Result); 105 | } 106 | }); 107 | 108 | Greeting[] greetings = 109 | { 110 | new Greeting() { FirstName = "John", LastName = "Doe" }, 111 | new Greeting() { FirstName = "Clement", LastName = "Jean" }, 112 | new Greeting() { FirstName = "Patricia", LastName = "Hertz" } 113 | }; 114 | 115 | foreach (var greeting in greetings) 116 | { 117 | Console.WriteLine("Sending : " + greeting.ToString()); 118 | await stream.RequestStream.WriteAsync(new GreetEveryoneRequest() 119 | { 120 | Greeting = greeting 121 | }); 122 | } 123 | 124 | await stream.RequestStream.CompleteAsync(); 125 | await responseReaderTask; 126 | } 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /blog/server/BlogServiceImpl.cs: -------------------------------------------------------------------------------- 1 | using Blog; 2 | using Grpc.Core; 3 | using MongoDB.Bson; 4 | using MongoDB.Driver; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using static Blog.BlogService; 10 | 11 | namespace server 12 | { 13 | public class BlogServiceImpl : BlogServiceBase 14 | { 15 | private static MongoClient mongoClient = new MongoClient("mongodb://localhost:27017"); 16 | private static IMongoDatabase mongoDatabase = mongoClient.GetDatabase("mybd"); 17 | private static IMongoCollection mongoCollection = mongoDatabase.GetCollection("blog"); 18 | 19 | public override Task CreateBlog(CreateBlogRequest request, ServerCallContext context) 20 | { 21 | var blog = request.Blog; 22 | BsonDocument doc = new BsonDocument("author_id", blog.AuthorId) 23 | .Add("title", blog.Title) 24 | .Add("content", blog.Content); 25 | 26 | mongoCollection.InsertOne(doc); 27 | 28 | String id = doc.GetValue("_id").ToString(); 29 | 30 | blog.Id = id; 31 | 32 | return Task.FromResult(new CreateBlogResponse() 33 | { 34 | Blog = blog 35 | }); 36 | } 37 | 38 | public override async Task ReadBlog(ReadBlogRequest request, ServerCallContext context) 39 | { 40 | var blogId = request.BlogId; 41 | 42 | var filter = new FilterDefinitionBuilder().Eq("_id", new ObjectId(blogId)); 43 | var result = mongoCollection.Find(filter).FirstOrDefault(); 44 | 45 | if (result == null) 46 | throw new RpcException(new Status(StatusCode.NotFound, "The blog id " + blogId + " wasn't find")); 47 | 48 | Blog.Blog blog = new Blog.Blog() 49 | { 50 | AuthorId = result.GetValue("author_id").AsString, 51 | Title = result.GetValue("title").AsString, 52 | Content = result.GetValue("content").AsString 53 | }; 54 | 55 | return new ReadBlogResponse() { Blog = blog }; 56 | } 57 | 58 | public override async Task UpdateBlog(UpdateBlogRequest request, ServerCallContext context) 59 | { 60 | var blogId = request.Blog.Id; 61 | 62 | var filter = new FilterDefinitionBuilder().Eq("_id", new ObjectId(blogId)); 63 | var result = mongoCollection.Find(filter).FirstOrDefault(); 64 | 65 | if (result == null) 66 | throw new RpcException(new Status(StatusCode.NotFound, "The blog id " + blogId + " wasn't find")); 67 | 68 | var doc = new BsonDocument("author_id", request.Blog.AuthorId) 69 | .Add("title", request.Blog.Title) 70 | .Add("content", request.Blog.Content); 71 | 72 | mongoCollection.ReplaceOne(filter, doc); 73 | 74 | var blog = new Blog.Blog() 75 | { 76 | AuthorId = doc.GetValue("author_id").AsString, 77 | Title = doc.GetValue("title").AsString, 78 | Content = doc.GetValue("content").AsString 79 | }; 80 | 81 | blog.Id = blogId; 82 | 83 | return new UpdateBlogResponse() { Blog = blog }; 84 | } 85 | 86 | public override async Task DeleteBlog(DeleteBlogRequest request, ServerCallContext context) 87 | { 88 | var blogId = request.BlogId; 89 | 90 | var filter = new FilterDefinitionBuilder().Eq("_id", new ObjectId(blogId)); 91 | 92 | var result = mongoCollection.DeleteOne(filter); 93 | 94 | if (result.DeletedCount == 0) 95 | throw new RpcException(new Status(StatusCode.NotFound, "The blog with id " + blogId + " wasn't find")); 96 | 97 | return new DeleteBlogRepsponse() { BlogId = blogId }; 98 | } 99 | 100 | public override async Task ListBlog(ListBlogRequest request, IServerStreamWriter responseStream, ServerCallContext context) 101 | { 102 | var filter = new FilterDefinitionBuilder().Empty; 103 | 104 | var result = mongoCollection.Find(filter); 105 | 106 | foreach (var item in result.ToList()) 107 | { 108 | await responseStream.WriteAsync(new ListBlogResponse() 109 | { 110 | Blog = new Blog.Blog() 111 | { 112 | Id = item.GetValue("_id").ToString(), 113 | AuthorId = item.GetValue("author_id").AsString, 114 | Content = item.GetValue("content").AsString, 115 | Title = item.GetValue("title").AsString 116 | } 117 | }); 118 | } 119 | } 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /exercises/compute-average/client/models/AverageGrpc.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Generated by the protocol buffer compiler. DO NOT EDIT! 3 | // source: average.proto 4 | // 5 | #pragma warning disable 0414, 1591 6 | #region Designer generated code 7 | 8 | using grpc = global::Grpc.Core; 9 | 10 | namespace Average { 11 | public static partial class AverageService 12 | { 13 | static readonly string __ServiceName = "average.AverageService"; 14 | 15 | static readonly grpc::Marshaller __Marshaller_average_AverageRequest = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Average.AverageRequest.Parser.ParseFrom); 16 | static readonly grpc::Marshaller __Marshaller_average_AverageResponse = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Average.AverageResponse.Parser.ParseFrom); 17 | 18 | static readonly grpc::Method __Method_ComputeAverage = new grpc::Method( 19 | grpc::MethodType.ClientStreaming, 20 | __ServiceName, 21 | "ComputeAverage", 22 | __Marshaller_average_AverageRequest, 23 | __Marshaller_average_AverageResponse); 24 | 25 | /// Service descriptor 26 | public static global::Google.Protobuf.Reflection.ServiceDescriptor Descriptor 27 | { 28 | get { return global::Average.AverageReflection.Descriptor.Services[0]; } 29 | } 30 | 31 | /// Base class for server-side implementations of AverageService 32 | [grpc::BindServiceMethod(typeof(AverageService), "BindService")] 33 | public abstract partial class AverageServiceBase 34 | { 35 | public virtual global::System.Threading.Tasks.Task ComputeAverage(grpc::IAsyncStreamReader requestStream, grpc::ServerCallContext context) 36 | { 37 | throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, "")); 38 | } 39 | 40 | } 41 | 42 | /// Client for AverageService 43 | public partial class AverageServiceClient : grpc::ClientBase 44 | { 45 | /// Creates a new client for AverageService 46 | /// The channel to use to make remote calls. 47 | public AverageServiceClient(grpc::ChannelBase channel) : base(channel) 48 | { 49 | } 50 | /// Creates a new client for AverageService that uses a custom CallInvoker. 51 | /// The callInvoker to use to make remote calls. 52 | public AverageServiceClient(grpc::CallInvoker callInvoker) : base(callInvoker) 53 | { 54 | } 55 | /// Protected parameterless constructor to allow creation of test doubles. 56 | protected AverageServiceClient() : base() 57 | { 58 | } 59 | /// Protected constructor to allow creation of configured clients. 60 | /// The client configuration. 61 | protected AverageServiceClient(ClientBaseConfiguration configuration) : base(configuration) 62 | { 63 | } 64 | 65 | public virtual grpc::AsyncClientStreamingCall ComputeAverage(grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) 66 | { 67 | return ComputeAverage(new grpc::CallOptions(headers, deadline, cancellationToken)); 68 | } 69 | public virtual grpc::AsyncClientStreamingCall ComputeAverage(grpc::CallOptions options) 70 | { 71 | return CallInvoker.AsyncClientStreamingCall(__Method_ComputeAverage, null, options); 72 | } 73 | /// Creates a new instance of client from given ClientBaseConfiguration. 74 | protected override AverageServiceClient NewInstance(ClientBaseConfiguration configuration) 75 | { 76 | return new AverageServiceClient(configuration); 77 | } 78 | } 79 | 80 | /// Creates service definition that can be registered with a server 81 | /// An object implementing the server-side handling logic. 82 | public static grpc::ServerServiceDefinition BindService(AverageServiceBase serviceImpl) 83 | { 84 | return grpc::ServerServiceDefinition.CreateBuilder() 85 | .AddMethod(__Method_ComputeAverage, serviceImpl.ComputeAverage).Build(); 86 | } 87 | 88 | /// Register service method with a service binder with or without implementation. Useful when customizing the service binding logic. 89 | /// Note: this method is part of an experimental API that can change or be removed without any prior notice. 90 | /// Service methods will be bound by calling AddMethod on this object. 91 | /// An object implementing the server-side handling logic. 92 | public static void BindService(grpc::ServiceBinderBase serviceBinder, AverageServiceBase serviceImpl) 93 | { 94 | serviceBinder.AddMethod(__Method_ComputeAverage, serviceImpl == null ? null : new grpc::ClientStreamingServerMethod(serviceImpl.ComputeAverage)); 95 | } 96 | 97 | } 98 | } 99 | #endregion 100 | -------------------------------------------------------------------------------- /exercises/compute-average/server/models/AverageGrpc.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Generated by the protocol buffer compiler. DO NOT EDIT! 3 | // source: average.proto 4 | // 5 | #pragma warning disable 0414, 1591 6 | #region Designer generated code 7 | 8 | using grpc = global::Grpc.Core; 9 | 10 | namespace Average { 11 | public static partial class AverageService 12 | { 13 | static readonly string __ServiceName = "average.AverageService"; 14 | 15 | static readonly grpc::Marshaller __Marshaller_average_AverageRequest = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Average.AverageRequest.Parser.ParseFrom); 16 | static readonly grpc::Marshaller __Marshaller_average_AverageResponse = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Average.AverageResponse.Parser.ParseFrom); 17 | 18 | static readonly grpc::Method __Method_ComputeAverage = new grpc::Method( 19 | grpc::MethodType.ClientStreaming, 20 | __ServiceName, 21 | "ComputeAverage", 22 | __Marshaller_average_AverageRequest, 23 | __Marshaller_average_AverageResponse); 24 | 25 | /// Service descriptor 26 | public static global::Google.Protobuf.Reflection.ServiceDescriptor Descriptor 27 | { 28 | get { return global::Average.AverageReflection.Descriptor.Services[0]; } 29 | } 30 | 31 | /// Base class for server-side implementations of AverageService 32 | [grpc::BindServiceMethod(typeof(AverageService), "BindService")] 33 | public abstract partial class AverageServiceBase 34 | { 35 | public virtual global::System.Threading.Tasks.Task ComputeAverage(grpc::IAsyncStreamReader requestStream, grpc::ServerCallContext context) 36 | { 37 | throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, "")); 38 | } 39 | 40 | } 41 | 42 | /// Client for AverageService 43 | public partial class AverageServiceClient : grpc::ClientBase 44 | { 45 | /// Creates a new client for AverageService 46 | /// The channel to use to make remote calls. 47 | public AverageServiceClient(grpc::ChannelBase channel) : base(channel) 48 | { 49 | } 50 | /// Creates a new client for AverageService that uses a custom CallInvoker. 51 | /// The callInvoker to use to make remote calls. 52 | public AverageServiceClient(grpc::CallInvoker callInvoker) : base(callInvoker) 53 | { 54 | } 55 | /// Protected parameterless constructor to allow creation of test doubles. 56 | protected AverageServiceClient() : base() 57 | { 58 | } 59 | /// Protected constructor to allow creation of configured clients. 60 | /// The client configuration. 61 | protected AverageServiceClient(ClientBaseConfiguration configuration) : base(configuration) 62 | { 63 | } 64 | 65 | public virtual grpc::AsyncClientStreamingCall ComputeAverage(grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) 66 | { 67 | return ComputeAverage(new grpc::CallOptions(headers, deadline, cancellationToken)); 68 | } 69 | public virtual grpc::AsyncClientStreamingCall ComputeAverage(grpc::CallOptions options) 70 | { 71 | return CallInvoker.AsyncClientStreamingCall(__Method_ComputeAverage, null, options); 72 | } 73 | /// Creates a new instance of client from given ClientBaseConfiguration. 74 | protected override AverageServiceClient NewInstance(ClientBaseConfiguration configuration) 75 | { 76 | return new AverageServiceClient(configuration); 77 | } 78 | } 79 | 80 | /// Creates service definition that can be registered with a server 81 | /// An object implementing the server-side handling logic. 82 | public static grpc::ServerServiceDefinition BindService(AverageServiceBase serviceImpl) 83 | { 84 | return grpc::ServerServiceDefinition.CreateBuilder() 85 | .AddMethod(__Method_ComputeAverage, serviceImpl.ComputeAverage).Build(); 86 | } 87 | 88 | /// Register service method with a service binder with or without implementation. Useful when customizing the service binding logic. 89 | /// Note: this method is part of an experimental API that can change or be removed without any prior notice. 90 | /// Service methods will be bound by calling AddMethod on this object. 91 | /// An object implementing the server-side handling logic. 92 | public static void BindService(grpc::ServiceBinderBase serviceBinder, AverageServiceBase serviceImpl) 93 | { 94 | serviceBinder.AddMethod(__Method_ComputeAverage, serviceImpl == null ? null : new grpc::ClientStreamingServerMethod(serviceImpl.ComputeAverage)); 95 | } 96 | 97 | } 98 | } 99 | #endregion 100 | -------------------------------------------------------------------------------- /exercises/sum-unary-api/client/client.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Debug 7 | AnyCPU 8 | {BAB76262-3B4D-4E1E-AC0A-C31874976C99} 9 | Exe 10 | client 11 | client 12 | v4.7.2 13 | 512 14 | true 15 | true 16 | 17 | 18 | 19 | 20 | AnyCPU 21 | true 22 | full 23 | false 24 | bin\Debug\ 25 | DEBUG;TRACE 26 | prompt 27 | 4 28 | 29 | 30 | AnyCPU 31 | pdbonly 32 | true 33 | bin\Release\ 34 | TRACE 35 | prompt 36 | 4 37 | 38 | 39 | 40 | ..\packages\Google.Protobuf.3.10.0\lib\net45\Google.Protobuf.dll 41 | 42 | 43 | ..\packages\Grpc.Core.2.24.0\lib\net45\Grpc.Core.dll 44 | 45 | 46 | ..\packages\Grpc.Core.Api.2.24.0\lib\net45\Grpc.Core.Api.dll 47 | 48 | 49 | 50 | ..\packages\System.Buffers.4.4.0\lib\netstandard2.0\System.Buffers.dll 51 | 52 | 53 | 54 | ..\packages\System.Memory.4.5.3\lib\netstandard2.0\System.Memory.dll 55 | 56 | 57 | 58 | ..\packages\System.Numerics.Vectors.4.4.0\lib\net46\System.Numerics.Vectors.dll 59 | 60 | 61 | ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. 89 | 90 | 91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /exercises/prime-number-decomposition/client/client.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Debug 7 | AnyCPU 8 | {087D7603-09D3-4B26-A5FB-5AC2B205C3F8} 9 | Exe 10 | client 11 | client 12 | v4.7.2 13 | 512 14 | true 15 | true 16 | 17 | 18 | 19 | 20 | AnyCPU 21 | true 22 | full 23 | false 24 | bin\Debug\ 25 | DEBUG;TRACE 26 | prompt 27 | 4 28 | 29 | 30 | AnyCPU 31 | pdbonly 32 | true 33 | bin\Release\ 34 | TRACE 35 | prompt 36 | 4 37 | 38 | 39 | 40 | ..\packages\Google.Protobuf.3.10.0\lib\net45\Google.Protobuf.dll 41 | 42 | 43 | ..\packages\Grpc.Core.2.24.0\lib\net45\Grpc.Core.dll 44 | 45 | 46 | ..\packages\Grpc.Core.Api.2.24.0\lib\net45\Grpc.Core.Api.dll 47 | 48 | 49 | 50 | ..\packages\System.Buffers.4.4.0\lib\netstandard2.0\System.Buffers.dll 51 | 52 | 53 | 54 | ..\packages\System.Memory.4.5.3\lib\netstandard2.0\System.Memory.dll 55 | 56 | 57 | 58 | ..\packages\System.Numerics.Vectors.4.4.0\lib\net46\System.Numerics.Vectors.dll 59 | 60 | 61 | ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. 89 | 90 | 91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /exercises/sum-unary-api/server/server.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Debug 7 | AnyCPU 8 | {2DD46579-E85A-4455-827C-248DE906B148} 9 | Exe 10 | server 11 | server 12 | v4.7.2 13 | 512 14 | true 15 | true 16 | 17 | 18 | 19 | 20 | AnyCPU 21 | true 22 | full 23 | false 24 | bin\Debug\ 25 | DEBUG;TRACE 26 | prompt 27 | 4 28 | 29 | 30 | AnyCPU 31 | pdbonly 32 | true 33 | bin\Release\ 34 | TRACE 35 | prompt 36 | 4 37 | 38 | 39 | 40 | ..\packages\Google.Protobuf.3.10.0\lib\net45\Google.Protobuf.dll 41 | 42 | 43 | ..\packages\Grpc.Core.2.24.0\lib\net45\Grpc.Core.dll 44 | 45 | 46 | ..\packages\Grpc.Core.Api.2.24.0\lib\net45\Grpc.Core.Api.dll 47 | 48 | 49 | 50 | ..\packages\System.Buffers.4.4.0\lib\netstandard2.0\System.Buffers.dll 51 | 52 | 53 | 54 | ..\packages\System.Memory.4.5.3\lib\netstandard2.0\System.Memory.dll 55 | 56 | 57 | 58 | ..\packages\System.Numerics.Vectors.4.4.0\lib\net46\System.Numerics.Vectors.dll 59 | 60 | 61 | ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. 90 | 91 | 92 | 93 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /exercises/prime-number-decomposition/server/server.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Debug 7 | AnyCPU 8 | {E60DDDA0-F6B0-4188-9315-18A325B7020D} 9 | Exe 10 | server 11 | server 12 | v4.7.2 13 | 512 14 | true 15 | true 16 | 17 | 18 | 19 | 20 | AnyCPU 21 | true 22 | full 23 | false 24 | bin\Debug\ 25 | DEBUG;TRACE 26 | prompt 27 | 4 28 | 29 | 30 | AnyCPU 31 | pdbonly 32 | true 33 | bin\Release\ 34 | TRACE 35 | prompt 36 | 4 37 | 38 | 39 | 40 | ..\packages\Google.Protobuf.3.10.0\lib\net45\Google.Protobuf.dll 41 | 42 | 43 | ..\packages\Grpc.Core.2.24.0\lib\net45\Grpc.Core.dll 44 | 45 | 46 | ..\packages\Grpc.Core.Api.2.24.0\lib\net45\Grpc.Core.Api.dll 47 | 48 | 49 | 50 | ..\packages\System.Buffers.4.4.0\lib\netstandard2.0\System.Buffers.dll 51 | 52 | 53 | 54 | ..\packages\System.Memory.4.5.3\lib\netstandard2.0\System.Memory.dll 55 | 56 | 57 | 58 | ..\packages\System.Numerics.Vectors.4.4.0\lib\net46\System.Numerics.Vectors.dll 59 | 60 | 61 | ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. 90 | 91 | 92 | 93 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /class/client/client.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Debug 7 | AnyCPU 8 | {B43DEA46-171B-4397-B9DA-2D16CD029CE2} 9 | Exe 10 | client 11 | client 12 | v4.7.2 13 | 512 14 | true 15 | true 16 | 17 | 18 | 19 | 20 | AnyCPU 21 | true 22 | full 23 | false 24 | bin\Debug\ 25 | DEBUG;TRACE 26 | prompt 27 | 4 28 | 29 | 30 | AnyCPU 31 | pdbonly 32 | true 33 | bin\Release\ 34 | TRACE 35 | prompt 36 | 4 37 | 38 | 39 | 40 | ..\packages\Google.Protobuf.3.10.0\lib\net45\Google.Protobuf.dll 41 | 42 | 43 | ..\packages\Grpc.Core.2.24.0\lib\net45\Grpc.Core.dll 44 | 45 | 46 | ..\packages\Grpc.Core.Api.2.24.0\lib\net45\Grpc.Core.Api.dll 47 | 48 | 49 | 50 | ..\packages\System.Buffers.4.4.0\lib\netstandard2.0\System.Buffers.dll 51 | 52 | 53 | 54 | ..\packages\System.Memory.4.5.3\lib\netstandard2.0\System.Memory.dll 55 | 56 | 57 | 58 | ..\packages\System.Numerics.Vectors.4.4.0\lib\net46\System.Numerics.Vectors.dll 59 | 60 | 61 | ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | PreserveNewest 82 | 83 | 84 | PreserveNewest 85 | 86 | 87 | PreserveNewest 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. 98 | 99 | 100 | 101 | 102 | 103 | 104 | -------------------------------------------------------------------------------- /class/server/server.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Debug 7 | AnyCPU 8 | {F101CBD9-E27E-4D1B-9A20-6B2E404714C8} 9 | Exe 10 | server 11 | server 12 | v4.7.2 13 | 512 14 | true 15 | true 16 | 17 | 18 | 19 | 20 | AnyCPU 21 | true 22 | full 23 | false 24 | bin\Debug\ 25 | DEBUG;TRACE 26 | prompt 27 | 4 28 | 29 | 30 | AnyCPU 31 | pdbonly 32 | true 33 | bin\Release\ 34 | TRACE 35 | prompt 36 | 4 37 | 38 | 39 | 40 | ..\packages\Google.Protobuf.3.10.0\lib\net45\Google.Protobuf.dll 41 | 42 | 43 | ..\packages\Grpc.Core.2.24.0\lib\net45\Grpc.Core.dll 44 | 45 | 46 | ..\packages\Grpc.Core.Api.2.24.0\lib\net45\Grpc.Core.Api.dll 47 | 48 | 49 | ..\packages\Grpc.Reflection.2.24.0\lib\net45\Grpc.Reflection.dll 50 | 51 | 52 | 53 | ..\packages\System.Buffers.4.4.0\lib\netstandard2.0\System.Buffers.dll 54 | 55 | 56 | 57 | ..\packages\System.Memory.4.5.3\lib\netstandard2.0\System.Memory.dll 58 | 59 | 60 | 61 | ..\packages\System.Numerics.Vectors.4.4.0\lib\net46\System.Numerics.Vectors.dll 62 | 63 | 64 | ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | PreserveNewest 86 | 87 | 88 | PreserveNewest 89 | 90 | 91 | PreserveNewest 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. 102 | 103 | 104 | 105 | 106 | 107 | 108 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.suo 8 | *.user 9 | *.userosscache 10 | *.sln.docstates 11 | 12 | # User-specific files (MonoDevelop/Xamarin Studio) 13 | *.userprefs 14 | 15 | # Build results 16 | [Dd]ebug/ 17 | [Dd]ebugPublic/ 18 | [Rr]elease/ 19 | [Rr]eleases/ 20 | x64/ 21 | x86/ 22 | bld/ 23 | [Bb]in/ 24 | [Oo]bj/ 25 | [Ll]og/ 26 | 27 | # Visual Studio 2015/2017 cache/options directory 28 | .vs/ 29 | # Uncomment if you have tasks that create the project's static files in wwwroot 30 | #wwwroot/ 31 | 32 | # Visual Studio 2017 auto generated files 33 | Generated\ Files/ 34 | 35 | # MSTest test Results 36 | [Tt]est[Rr]esult*/ 37 | [Bb]uild[Ll]og.* 38 | 39 | # NUNIT 40 | *.VisualState.xml 41 | TestResult.xml 42 | 43 | # Build Results of an ATL Project 44 | [Dd]ebugPS/ 45 | [Rr]eleasePS/ 46 | dlldata.c 47 | 48 | # Benchmark Results 49 | BenchmarkDotNet.Artifacts/ 50 | 51 | # .NET Core 52 | project.lock.json 53 | project.fragment.lock.json 54 | artifacts/ 55 | **/Properties/launchSettings.json 56 | 57 | # StyleCop 58 | StyleCopReport.xml 59 | 60 | # Files built by Visual Studio 61 | *_i.c 62 | *_p.c 63 | *_i.h 64 | *.ilk 65 | *.meta 66 | *.obj 67 | *.iobj 68 | *.pch 69 | *.pdb 70 | *.ipdb 71 | *.pgc 72 | *.pgd 73 | *.rsp 74 | *.sbr 75 | *.tlb 76 | *.tli 77 | *.tlh 78 | *.tmp 79 | *.tmp_proj 80 | *.log 81 | *.vspscc 82 | *.vssscc 83 | .builds 84 | *.pidb 85 | *.svclog 86 | *.scc 87 | 88 | # Chutzpah Test files 89 | _Chutzpah* 90 | 91 | # Visual C++ cache files 92 | ipch/ 93 | *.aps 94 | *.ncb 95 | *.opendb 96 | *.opensdf 97 | *.sdf 98 | *.cachefile 99 | *.VC.db 100 | *.VC.VC.opendb 101 | 102 | # Visual Studio profiler 103 | *.psess 104 | *.vsp 105 | *.vspx 106 | *.sap 107 | 108 | # Visual Studio Trace Files 109 | *.e2e 110 | 111 | # TFS 2012 Local Workspace 112 | $tf/ 113 | 114 | # Guidance Automation Toolkit 115 | *.gpState 116 | 117 | # ReSharper is a .NET coding add-in 118 | _ReSharper*/ 119 | *.[Rr]e[Ss]harper 120 | *.DotSettings.user 121 | 122 | # JustCode is a .NET coding add-in 123 | .JustCode 124 | 125 | # TeamCity is a build add-in 126 | _TeamCity* 127 | 128 | # DotCover is a Code Coverage Tool 129 | *.dotCover 130 | 131 | # AxoCover is a Code Coverage Tool 132 | .axoCover/* 133 | !.axoCover/settings.json 134 | 135 | # Visual Studio code coverage results 136 | *.coverage 137 | *.coveragexml 138 | 139 | # NCrunch 140 | _NCrunch_* 141 | .*crunch*.local.xml 142 | nCrunchTemp_* 143 | 144 | # MightyMoose 145 | *.mm.* 146 | AutoTest.Net/ 147 | 148 | # Web workbench (sass) 149 | .sass-cache/ 150 | 151 | # Installshield output folder 152 | [Ee]xpress/ 153 | 154 | # DocProject is a documentation generator add-in 155 | DocProject/buildhelp/ 156 | DocProject/Help/*.HxT 157 | DocProject/Help/*.HxC 158 | DocProject/Help/*.hhc 159 | DocProject/Help/*.hhk 160 | DocProject/Help/*.hhp 161 | DocProject/Help/Html2 162 | DocProject/Help/html 163 | 164 | # Click-Once directory 165 | publish/ 166 | 167 | # Publish Web Output 168 | *.[Pp]ublish.xml 169 | *.azurePubxml 170 | # Note: Comment the next line if you want to checkin your web deploy settings, 171 | # but database connection strings (with potential passwords) will be unencrypted 172 | *.pubxml 173 | *.publishproj 174 | 175 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 176 | # checkin your Azure Web App publish settings, but sensitive information contained 177 | # in these scripts will be unencrypted 178 | PublishScripts/ 179 | 180 | # NuGet Packages 181 | *.nupkg 182 | # The packages folder can be ignored because of Package Restore 183 | **/[Pp]ackages/* 184 | # except build/, which is used as an MSBuild target. 185 | !**/[Pp]ackages/build/ 186 | # Uncomment if necessary however generally it will be regenerated when needed 187 | #!**/[Pp]ackages/repositories.config 188 | # NuGet v3's project.json files produces more ignorable files 189 | *.nuget.props 190 | *.nuget.targets 191 | 192 | # Microsoft Azure Build Output 193 | csx/ 194 | *.build.csdef 195 | 196 | # Microsoft Azure Emulator 197 | ecf/ 198 | rcf/ 199 | 200 | # Windows Store app package directories and files 201 | AppPackages/ 202 | BundleArtifacts/ 203 | Package.StoreAssociation.xml 204 | _pkginfo.txt 205 | *.appx 206 | 207 | # Visual Studio cache files 208 | # files ending in .cache can be ignored 209 | *.[Cc]ache 210 | # but keep track of directories ending in .cache 211 | !*.[Cc]ache/ 212 | 213 | # Others 214 | ClientBin/ 215 | ~$* 216 | *~ 217 | *.dbmdl 218 | *.dbproj.schemaview 219 | *.jfm 220 | *.pfx 221 | *.publishsettings 222 | orleans.codegen.cs 223 | 224 | # Including strong name files can present a security risk 225 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 226 | #*.snk 227 | 228 | # Since there are multiple workflows, uncomment next line to ignore bower_components 229 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 230 | #bower_components/ 231 | 232 | # RIA/Silverlight projects 233 | Generated_Code/ 234 | 235 | # Backup & report files from converting an old project file 236 | # to a newer Visual Studio version. Backup files are not needed, 237 | # because we have git ;-) 238 | _UpgradeReport_Files/ 239 | Backup*/ 240 | UpgradeLog*.XML 241 | UpgradeLog*.htm 242 | ServiceFabricBackup/ 243 | *.rptproj.bak 244 | 245 | # SQL Server files 246 | *.mdf 247 | *.ldf 248 | *.ndf 249 | 250 | # Business Intelligence projects 251 | *.rdl.data 252 | *.bim.layout 253 | *.bim_*.settings 254 | *.rptproj.rsuser 255 | 256 | # Microsoft Fakes 257 | FakesAssemblies/ 258 | 259 | # GhostDoc plugin setting file 260 | *.GhostDoc.xml 261 | 262 | # Node.js Tools for Visual Studio 263 | .ntvs_analysis.dat 264 | node_modules/ 265 | 266 | # Visual Studio 6 build log 267 | *.plg 268 | 269 | # Visual Studio 6 workspace options file 270 | *.opt 271 | 272 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 273 | *.vbw 274 | 275 | # Visual Studio LightSwitch build output 276 | **/*.HTMLClient/GeneratedArtifacts 277 | **/*.DesktopClient/GeneratedArtifacts 278 | **/*.DesktopClient/ModelManifest.xml 279 | **/*.Server/GeneratedArtifacts 280 | **/*.Server/ModelManifest.xml 281 | _Pvt_Extensions 282 | 283 | # Paket dependency manager 284 | .paket/paket.exe 285 | paket-files/ 286 | 287 | # FAKE - F# Make 288 | .fake/ 289 | 290 | # JetBrains Rider 291 | .idea/ 292 | *.sln.iml 293 | 294 | # CodeRush 295 | .cr/ 296 | 297 | # Python Tools for Visual Studio (PTVS) 298 | __pycache__/ 299 | *.pyc 300 | 301 | # Cake - Uncomment if you are using it 302 | # tools/** 303 | # !tools/packages.config 304 | 305 | # Tabs Studio 306 | *.tss 307 | 308 | # Telerik's JustMock configuration file 309 | *.jmconfig 310 | 311 | # BizTalk build output 312 | *.btp.cs 313 | *.btm.cs 314 | *.odx.cs 315 | *.xsd.cs 316 | 317 | # OpenCover UI analysis results 318 | OpenCover/ 319 | 320 | # Azure Stream Analytics local run output 321 | ASALocalRun/ 322 | 323 | # MSBuild Binary and Structured Log 324 | *.binlog 325 | 326 | # NVidia Nsight GPU debugger configuration file 327 | *.nvuser 328 | 329 | # MFractors (Xamarin productivity tool) working folder 330 | .mfractor/ 331 | -------------------------------------------------------------------------------- /exercises/compute-average/client/models/Average.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Generated by the protocol buffer compiler. DO NOT EDIT! 3 | // source: average.proto 4 | // 5 | #pragma warning disable 1591, 0612, 3021 6 | #region Designer generated code 7 | 8 | using pb = global::Google.Protobuf; 9 | using pbc = global::Google.Protobuf.Collections; 10 | using pbr = global::Google.Protobuf.Reflection; 11 | using scg = global::System.Collections.Generic; 12 | namespace Average { 13 | 14 | /// Holder for reflection information generated from average.proto 15 | public static partial class AverageReflection { 16 | 17 | #region Descriptor 18 | /// File descriptor for average.proto 19 | public static pbr::FileDescriptor Descriptor { 20 | get { return descriptor; } 21 | } 22 | private static pbr::FileDescriptor descriptor; 23 | 24 | static AverageReflection() { 25 | byte[] descriptorData = global::System.Convert.FromBase64String( 26 | string.Concat( 27 | "Cg1hdmVyYWdlLnByb3RvEgdhdmVyYWdlIiAKDkF2ZXJhZ2VSZXF1ZXN0Eg4K", 28 | "Bm51bWJlchgBIAEoBSIhCg9BdmVyYWdlUmVzcG9uc2USDgoGcmVzdWx0GAEg", 29 | "ASgBMlkKDkF2ZXJhZ2VTZXJ2aWNlEkcKDkNvbXB1dGVBdmVyYWdlEhcuYXZl", 30 | "cmFnZS5BdmVyYWdlUmVxdWVzdBoYLmF2ZXJhZ2UuQXZlcmFnZVJlc3BvbnNl", 31 | "IgAoAWIGcHJvdG8z")); 32 | descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, 33 | new pbr::FileDescriptor[] { }, 34 | new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { 35 | new pbr::GeneratedClrTypeInfo(typeof(global::Average.AverageRequest), global::Average.AverageRequest.Parser, new[]{ "Number" }, null, null, null), 36 | new pbr::GeneratedClrTypeInfo(typeof(global::Average.AverageResponse), global::Average.AverageResponse.Parser, new[]{ "Result" }, null, null, null) 37 | })); 38 | } 39 | #endregion 40 | 41 | } 42 | #region Messages 43 | public sealed partial class AverageRequest : pb::IMessage { 44 | private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new AverageRequest()); 45 | private pb::UnknownFieldSet _unknownFields; 46 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 47 | public static pb::MessageParser Parser { get { return _parser; } } 48 | 49 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 50 | public static pbr::MessageDescriptor Descriptor { 51 | get { return global::Average.AverageReflection.Descriptor.MessageTypes[0]; } 52 | } 53 | 54 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 55 | pbr::MessageDescriptor pb::IMessage.Descriptor { 56 | get { return Descriptor; } 57 | } 58 | 59 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 60 | public AverageRequest() { 61 | OnConstruction(); 62 | } 63 | 64 | partial void OnConstruction(); 65 | 66 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 67 | public AverageRequest(AverageRequest other) : this() { 68 | number_ = other.number_; 69 | _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); 70 | } 71 | 72 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 73 | public AverageRequest Clone() { 74 | return new AverageRequest(this); 75 | } 76 | 77 | /// Field number for the "number" field. 78 | public const int NumberFieldNumber = 1; 79 | private int number_; 80 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 81 | public int Number { 82 | get { return number_; } 83 | set { 84 | number_ = value; 85 | } 86 | } 87 | 88 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 89 | public override bool Equals(object other) { 90 | return Equals(other as AverageRequest); 91 | } 92 | 93 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 94 | public bool Equals(AverageRequest other) { 95 | if (ReferenceEquals(other, null)) { 96 | return false; 97 | } 98 | if (ReferenceEquals(other, this)) { 99 | return true; 100 | } 101 | if (Number != other.Number) return false; 102 | return Equals(_unknownFields, other._unknownFields); 103 | } 104 | 105 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 106 | public override int GetHashCode() { 107 | int hash = 1; 108 | if (Number != 0) hash ^= Number.GetHashCode(); 109 | if (_unknownFields != null) { 110 | hash ^= _unknownFields.GetHashCode(); 111 | } 112 | return hash; 113 | } 114 | 115 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 116 | public override string ToString() { 117 | return pb::JsonFormatter.ToDiagnosticString(this); 118 | } 119 | 120 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 121 | public void WriteTo(pb::CodedOutputStream output) { 122 | if (Number != 0) { 123 | output.WriteRawTag(8); 124 | output.WriteInt32(Number); 125 | } 126 | if (_unknownFields != null) { 127 | _unknownFields.WriteTo(output); 128 | } 129 | } 130 | 131 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 132 | public int CalculateSize() { 133 | int size = 0; 134 | if (Number != 0) { 135 | size += 1 + pb::CodedOutputStream.ComputeInt32Size(Number); 136 | } 137 | if (_unknownFields != null) { 138 | size += _unknownFields.CalculateSize(); 139 | } 140 | return size; 141 | } 142 | 143 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 144 | public void MergeFrom(AverageRequest other) { 145 | if (other == null) { 146 | return; 147 | } 148 | if (other.Number != 0) { 149 | Number = other.Number; 150 | } 151 | _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); 152 | } 153 | 154 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 155 | public void MergeFrom(pb::CodedInputStream input) { 156 | uint tag; 157 | while ((tag = input.ReadTag()) != 0) { 158 | switch(tag) { 159 | default: 160 | _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); 161 | break; 162 | case 8: { 163 | Number = input.ReadInt32(); 164 | break; 165 | } 166 | } 167 | } 168 | } 169 | 170 | } 171 | 172 | public sealed partial class AverageResponse : pb::IMessage { 173 | private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new AverageResponse()); 174 | private pb::UnknownFieldSet _unknownFields; 175 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 176 | public static pb::MessageParser Parser { get { return _parser; } } 177 | 178 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 179 | public static pbr::MessageDescriptor Descriptor { 180 | get { return global::Average.AverageReflection.Descriptor.MessageTypes[1]; } 181 | } 182 | 183 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 184 | pbr::MessageDescriptor pb::IMessage.Descriptor { 185 | get { return Descriptor; } 186 | } 187 | 188 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 189 | public AverageResponse() { 190 | OnConstruction(); 191 | } 192 | 193 | partial void OnConstruction(); 194 | 195 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 196 | public AverageResponse(AverageResponse other) : this() { 197 | result_ = other.result_; 198 | _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); 199 | } 200 | 201 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 202 | public AverageResponse Clone() { 203 | return new AverageResponse(this); 204 | } 205 | 206 | /// Field number for the "result" field. 207 | public const int ResultFieldNumber = 1; 208 | private double result_; 209 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 210 | public double Result { 211 | get { return result_; } 212 | set { 213 | result_ = value; 214 | } 215 | } 216 | 217 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 218 | public override bool Equals(object other) { 219 | return Equals(other as AverageResponse); 220 | } 221 | 222 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 223 | public bool Equals(AverageResponse other) { 224 | if (ReferenceEquals(other, null)) { 225 | return false; 226 | } 227 | if (ReferenceEquals(other, this)) { 228 | return true; 229 | } 230 | if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(Result, other.Result)) return false; 231 | return Equals(_unknownFields, other._unknownFields); 232 | } 233 | 234 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 235 | public override int GetHashCode() { 236 | int hash = 1; 237 | if (Result != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(Result); 238 | if (_unknownFields != null) { 239 | hash ^= _unknownFields.GetHashCode(); 240 | } 241 | return hash; 242 | } 243 | 244 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 245 | public override string ToString() { 246 | return pb::JsonFormatter.ToDiagnosticString(this); 247 | } 248 | 249 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 250 | public void WriteTo(pb::CodedOutputStream output) { 251 | if (Result != 0D) { 252 | output.WriteRawTag(9); 253 | output.WriteDouble(Result); 254 | } 255 | if (_unknownFields != null) { 256 | _unknownFields.WriteTo(output); 257 | } 258 | } 259 | 260 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 261 | public int CalculateSize() { 262 | int size = 0; 263 | if (Result != 0D) { 264 | size += 1 + 8; 265 | } 266 | if (_unknownFields != null) { 267 | size += _unknownFields.CalculateSize(); 268 | } 269 | return size; 270 | } 271 | 272 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 273 | public void MergeFrom(AverageResponse other) { 274 | if (other == null) { 275 | return; 276 | } 277 | if (other.Result != 0D) { 278 | Result = other.Result; 279 | } 280 | _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); 281 | } 282 | 283 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 284 | public void MergeFrom(pb::CodedInputStream input) { 285 | uint tag; 286 | while ((tag = input.ReadTag()) != 0) { 287 | switch(tag) { 288 | default: 289 | _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); 290 | break; 291 | case 9: { 292 | Result = input.ReadDouble(); 293 | break; 294 | } 295 | } 296 | } 297 | } 298 | 299 | } 300 | 301 | #endregion 302 | 303 | } 304 | 305 | #endregion Designer generated code 306 | -------------------------------------------------------------------------------- /exercises/compute-average/server/models/Average.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Generated by the protocol buffer compiler. DO NOT EDIT! 3 | // source: average.proto 4 | // 5 | #pragma warning disable 1591, 0612, 3021 6 | #region Designer generated code 7 | 8 | using pb = global::Google.Protobuf; 9 | using pbc = global::Google.Protobuf.Collections; 10 | using pbr = global::Google.Protobuf.Reflection; 11 | using scg = global::System.Collections.Generic; 12 | namespace Average { 13 | 14 | /// Holder for reflection information generated from average.proto 15 | public static partial class AverageReflection { 16 | 17 | #region Descriptor 18 | /// File descriptor for average.proto 19 | public static pbr::FileDescriptor Descriptor { 20 | get { return descriptor; } 21 | } 22 | private static pbr::FileDescriptor descriptor; 23 | 24 | static AverageReflection() { 25 | byte[] descriptorData = global::System.Convert.FromBase64String( 26 | string.Concat( 27 | "Cg1hdmVyYWdlLnByb3RvEgdhdmVyYWdlIiAKDkF2ZXJhZ2VSZXF1ZXN0Eg4K", 28 | "Bm51bWJlchgBIAEoBSIhCg9BdmVyYWdlUmVzcG9uc2USDgoGcmVzdWx0GAEg", 29 | "ASgBMlkKDkF2ZXJhZ2VTZXJ2aWNlEkcKDkNvbXB1dGVBdmVyYWdlEhcuYXZl", 30 | "cmFnZS5BdmVyYWdlUmVxdWVzdBoYLmF2ZXJhZ2UuQXZlcmFnZVJlc3BvbnNl", 31 | "IgAoAWIGcHJvdG8z")); 32 | descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, 33 | new pbr::FileDescriptor[] { }, 34 | new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { 35 | new pbr::GeneratedClrTypeInfo(typeof(global::Average.AverageRequest), global::Average.AverageRequest.Parser, new[]{ "Number" }, null, null, null), 36 | new pbr::GeneratedClrTypeInfo(typeof(global::Average.AverageResponse), global::Average.AverageResponse.Parser, new[]{ "Result" }, null, null, null) 37 | })); 38 | } 39 | #endregion 40 | 41 | } 42 | #region Messages 43 | public sealed partial class AverageRequest : pb::IMessage { 44 | private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new AverageRequest()); 45 | private pb::UnknownFieldSet _unknownFields; 46 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 47 | public static pb::MessageParser Parser { get { return _parser; } } 48 | 49 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 50 | public static pbr::MessageDescriptor Descriptor { 51 | get { return global::Average.AverageReflection.Descriptor.MessageTypes[0]; } 52 | } 53 | 54 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 55 | pbr::MessageDescriptor pb::IMessage.Descriptor { 56 | get { return Descriptor; } 57 | } 58 | 59 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 60 | public AverageRequest() { 61 | OnConstruction(); 62 | } 63 | 64 | partial void OnConstruction(); 65 | 66 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 67 | public AverageRequest(AverageRequest other) : this() { 68 | number_ = other.number_; 69 | _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); 70 | } 71 | 72 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 73 | public AverageRequest Clone() { 74 | return new AverageRequest(this); 75 | } 76 | 77 | /// Field number for the "number" field. 78 | public const int NumberFieldNumber = 1; 79 | private int number_; 80 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 81 | public int Number { 82 | get { return number_; } 83 | set { 84 | number_ = value; 85 | } 86 | } 87 | 88 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 89 | public override bool Equals(object other) { 90 | return Equals(other as AverageRequest); 91 | } 92 | 93 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 94 | public bool Equals(AverageRequest other) { 95 | if (ReferenceEquals(other, null)) { 96 | return false; 97 | } 98 | if (ReferenceEquals(other, this)) { 99 | return true; 100 | } 101 | if (Number != other.Number) return false; 102 | return Equals(_unknownFields, other._unknownFields); 103 | } 104 | 105 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 106 | public override int GetHashCode() { 107 | int hash = 1; 108 | if (Number != 0) hash ^= Number.GetHashCode(); 109 | if (_unknownFields != null) { 110 | hash ^= _unknownFields.GetHashCode(); 111 | } 112 | return hash; 113 | } 114 | 115 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 116 | public override string ToString() { 117 | return pb::JsonFormatter.ToDiagnosticString(this); 118 | } 119 | 120 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 121 | public void WriteTo(pb::CodedOutputStream output) { 122 | if (Number != 0) { 123 | output.WriteRawTag(8); 124 | output.WriteInt32(Number); 125 | } 126 | if (_unknownFields != null) { 127 | _unknownFields.WriteTo(output); 128 | } 129 | } 130 | 131 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 132 | public int CalculateSize() { 133 | int size = 0; 134 | if (Number != 0) { 135 | size += 1 + pb::CodedOutputStream.ComputeInt32Size(Number); 136 | } 137 | if (_unknownFields != null) { 138 | size += _unknownFields.CalculateSize(); 139 | } 140 | return size; 141 | } 142 | 143 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 144 | public void MergeFrom(AverageRequest other) { 145 | if (other == null) { 146 | return; 147 | } 148 | if (other.Number != 0) { 149 | Number = other.Number; 150 | } 151 | _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); 152 | } 153 | 154 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 155 | public void MergeFrom(pb::CodedInputStream input) { 156 | uint tag; 157 | while ((tag = input.ReadTag()) != 0) { 158 | switch(tag) { 159 | default: 160 | _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); 161 | break; 162 | case 8: { 163 | Number = input.ReadInt32(); 164 | break; 165 | } 166 | } 167 | } 168 | } 169 | 170 | } 171 | 172 | public sealed partial class AverageResponse : pb::IMessage { 173 | private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new AverageResponse()); 174 | private pb::UnknownFieldSet _unknownFields; 175 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 176 | public static pb::MessageParser Parser { get { return _parser; } } 177 | 178 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 179 | public static pbr::MessageDescriptor Descriptor { 180 | get { return global::Average.AverageReflection.Descriptor.MessageTypes[1]; } 181 | } 182 | 183 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 184 | pbr::MessageDescriptor pb::IMessage.Descriptor { 185 | get { return Descriptor; } 186 | } 187 | 188 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 189 | public AverageResponse() { 190 | OnConstruction(); 191 | } 192 | 193 | partial void OnConstruction(); 194 | 195 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 196 | public AverageResponse(AverageResponse other) : this() { 197 | result_ = other.result_; 198 | _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); 199 | } 200 | 201 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 202 | public AverageResponse Clone() { 203 | return new AverageResponse(this); 204 | } 205 | 206 | /// Field number for the "result" field. 207 | public const int ResultFieldNumber = 1; 208 | private double result_; 209 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 210 | public double Result { 211 | get { return result_; } 212 | set { 213 | result_ = value; 214 | } 215 | } 216 | 217 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 218 | public override bool Equals(object other) { 219 | return Equals(other as AverageResponse); 220 | } 221 | 222 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 223 | public bool Equals(AverageResponse other) { 224 | if (ReferenceEquals(other, null)) { 225 | return false; 226 | } 227 | if (ReferenceEquals(other, this)) { 228 | return true; 229 | } 230 | if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(Result, other.Result)) return false; 231 | return Equals(_unknownFields, other._unknownFields); 232 | } 233 | 234 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 235 | public override int GetHashCode() { 236 | int hash = 1; 237 | if (Result != 0D) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(Result); 238 | if (_unknownFields != null) { 239 | hash ^= _unknownFields.GetHashCode(); 240 | } 241 | return hash; 242 | } 243 | 244 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 245 | public override string ToString() { 246 | return pb::JsonFormatter.ToDiagnosticString(this); 247 | } 248 | 249 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 250 | public void WriteTo(pb::CodedOutputStream output) { 251 | if (Result != 0D) { 252 | output.WriteRawTag(9); 253 | output.WriteDouble(Result); 254 | } 255 | if (_unknownFields != null) { 256 | _unknownFields.WriteTo(output); 257 | } 258 | } 259 | 260 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 261 | public int CalculateSize() { 262 | int size = 0; 263 | if (Result != 0D) { 264 | size += 1 + 8; 265 | } 266 | if (_unknownFields != null) { 267 | size += _unknownFields.CalculateSize(); 268 | } 269 | return size; 270 | } 271 | 272 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 273 | public void MergeFrom(AverageResponse other) { 274 | if (other == null) { 275 | return; 276 | } 277 | if (other.Result != 0D) { 278 | Result = other.Result; 279 | } 280 | _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); 281 | } 282 | 283 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 284 | public void MergeFrom(pb::CodedInputStream input) { 285 | uint tag; 286 | while ((tag = input.ReadTag()) != 0) { 287 | switch(tag) { 288 | default: 289 | _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); 290 | break; 291 | case 9: { 292 | Result = input.ReadDouble(); 293 | break; 294 | } 295 | } 296 | } 297 | } 298 | 299 | } 300 | 301 | #endregion 302 | 303 | } 304 | 305 | #endregion Designer generated code 306 | --------------------------------------------------------------------------------