aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/csharp/GrpcCore/Internal/SafeHandleZeroIsInvalid.cs
diff options
context:
space:
mode:
authorGravatar Jan Tattermusch <jtattermusch@google.com>2015-02-03 17:54:38 -0800
committerGravatar Jan Tattermusch <jtattermusch@google.com>2015-02-03 18:11:10 -0800
commita7608b081e30f6fef5fd36935f8c8591381d4bde (patch)
tree43c7d282a57a969cc5272422f431c270cd5ba3be /src/csharp/GrpcCore/Internal/SafeHandleZeroIsInvalid.cs
parentea6f6d99f46cc0445840408da8d6096405fc209c (diff)
Prototype of gRPC C# library (Core and API examples)
Diffstat (limited to 'src/csharp/GrpcCore/Internal/SafeHandleZeroIsInvalid.cs')
-rw-r--r--src/csharp/GrpcCore/Internal/SafeHandleZeroIsInvalid.cs28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/csharp/GrpcCore/Internal/SafeHandleZeroIsInvalid.cs b/src/csharp/GrpcCore/Internal/SafeHandleZeroIsInvalid.cs
new file mode 100644
index 0000000000..5a1252b881
--- /dev/null
+++ b/src/csharp/GrpcCore/Internal/SafeHandleZeroIsInvalid.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Runtime.InteropServices;
+
+namespace Google.GRPC.Core.Internal
+{
+ /// <summary>
+ /// Safe handle to wrap native objects.
+ /// </summary>
+ internal abstract class SafeHandleZeroIsInvalid : SafeHandle
+ {
+ public SafeHandleZeroIsInvalid() : base(IntPtr.Zero, true)
+ {
+ }
+
+ public SafeHandleZeroIsInvalid(bool ownsHandle) : base(IntPtr.Zero, ownsHandle)
+ {
+ }
+
+ public override bool IsInvalid
+ {
+ get
+ {
+ return handle == IntPtr.Zero;
+ }
+ }
+ }
+}
+