aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/csharp/Grpc.Core/Interceptors/ChannelExtensions.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/csharp/Grpc.Core/Interceptors/ChannelExtensions.cs')
-rw-r--r--src/csharp/Grpc.Core/Interceptors/ChannelExtensions.cs54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/csharp/Grpc.Core/Interceptors/ChannelExtensions.cs b/src/csharp/Grpc.Core/Interceptors/ChannelExtensions.cs
new file mode 100644
index 0000000000..1a54b93dae
--- /dev/null
+++ b/src/csharp/Grpc.Core/Interceptors/ChannelExtensions.cs
@@ -0,0 +1,54 @@
+#region Copyright notice and license
+
+// Copyright 2018 gRPC authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#endregion
+
+using System;
+
+namespace Grpc.Core.Interceptors
+{
+ /// <summary>
+ /// Provides extension methods to make it easy to register interceptors on Channel objects.
+ /// This is an EXPERIMENTAL API.
+ /// </summary>
+ public static class ChannelExtensions
+ {
+ /// <summary>
+ /// Returns a <see cref="Grpc.Core.CallInvoker" /> instance that intercepts
+ /// the channel with the given interceptor.
+ /// </summary>
+ /// <param name="channel">The channel to intercept.</param>
+ /// <param name="interceptor">The interceptor to intercept the channel with.</param>
+ public static CallInvoker Intercept(this Channel channel, Interceptor interceptor)
+ {
+ return new DefaultCallInvoker(channel).Intercept(interceptor);
+ }
+
+ /// <summary>
+ /// Returns a <see cref="Grpc.Core.CallInvoker" /> instance that intercepts
+ /// the channel with the given interceptors.
+ /// </summary>
+ /// <param name="channel">The channel to intercept.</param>
+ /// <param name="interceptors">
+ /// An array of interceptors to intercept the channel with.
+ /// Control is passed to the interceptors in the order specified.
+ /// </param>
+ public static CallInvoker Intercept(this Channel channel, params Interceptor[] interceptors)
+ {
+ return new DefaultCallInvoker(channel).Intercept(interceptors);
+ }
+ }
+}