From c1d2ecb2783a857393b1a1631cb46a551d5ba1c0 Mon Sep 17 00:00:00 2001
From: Mathieu Leenhardt <mathieu.leenhardt@gmail.com>
Date: Thu, 4 Feb 2016 22:32:14 +0100
Subject: [PATCH] Added fluent methods for WriteOptions,
 ContextPropagationToken and CallCredentials

---
 src/csharp/Grpc.Core/CallOptions.cs | 51 ++++++++++++++++++++++-------
 1 file changed, 39 insertions(+), 12 deletions(-)

diff --git a/src/csharp/Grpc.Core/CallOptions.cs b/src/csharp/Grpc.Core/CallOptions.cs
index 1fda80cb90..339552b0b1 100644
--- a/src/csharp/Grpc.Core/CallOptions.cs
+++ b/src/csharp/Grpc.Core/CallOptions.cs
@@ -100,10 +100,7 @@ namespace Grpc.Core
         /// </summary>
         public WriteOptions WriteOptions
         {
-            get
-            {
-                return this.writeOptions;
-            }
+            get { return this.writeOptions; }
         }
 
         /// <summary>
@@ -111,10 +108,7 @@ namespace Grpc.Core
         /// </summary>
         public ContextPropagationToken PropagationToken
         {
-            get
-            {
-                return this.propagationToken;
-            }
+            get { return this.propagationToken; }
         }
 
         /// <summary>
@@ -122,10 +116,7 @@ namespace Grpc.Core
         /// </summary>
         public CallCredentials Credentials
         {
-            get
-            {
-                return this.credentials;
-            }
+            get { return this.credentials; }
         }
 
         /// <summary>
@@ -164,6 +155,42 @@ namespace Grpc.Core
             return newOptions;
         }
 
+        /// <summary>
+        /// Returns new instance of <see cref="CallOptions"/> with
+        /// <c>WriteOptions</c> set to the value provided. Values of all other fields are preserved.
+        /// </summary>
+        /// <param name="cancellationToken">The write options.</param>
+        public CallOptions WithWriteOptions(WriteOptions writeOptions)
+        {
+            var newOptions = this;
+            newOptions.writeOptions = writeOptions;
+            return newOptions;
+        }
+
+        /// <summary>
+        /// Returns new instance of <see cref="CallOptions"/> with
+        /// <c>PropagationToken</c> set to the value provided. Values of all other fields are preserved.
+        /// </summary>
+        /// <param name="propagationToken">The context propagation token.</param>
+        public CallOptions WithPropagationToken(ContextPropagationToken propagationToken)
+        {
+            var newOptions = this;
+            newOptions.propagationToken = propagationToken;
+            return newOptions;
+        }
+
+        /// <summary>
+        /// Returns new instance of <see cref="CallOptions"/> with
+        /// <c>Credentials</c> set to the value provided. Values of all other fields are preserved.
+        /// </summary>
+        /// <param name="credentials">The call credentials.</param>
+        public CallOptions WithCredentials(CallCredentials credentials)
+        {
+            var newOptions = this;
+            newOptions.credentials = credentials;
+            return newOptions;
+        }
+
         /// <summary>
         /// Returns a new instance of <see cref="CallOptions"/> with 
         /// all previously unset values set to their defaults and deadline and cancellation
-- 
GitLab