diff options
Diffstat (limited to 'src/mscorlib/shared/Microsoft/Win32/SafeHandles/SafeHandleMinusOneIsInvalid.cs')
-rw-r--r-- | src/mscorlib/shared/Microsoft/Win32/SafeHandles/SafeHandleMinusOneIsInvalid.cs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/mscorlib/shared/Microsoft/Win32/SafeHandles/SafeHandleMinusOneIsInvalid.cs b/src/mscorlib/shared/Microsoft/Win32/SafeHandles/SafeHandleMinusOneIsInvalid.cs new file mode 100644 index 0000000000..5415f2c35d --- /dev/null +++ b/src/mscorlib/shared/Microsoft/Win32/SafeHandles/SafeHandleMinusOneIsInvalid.cs @@ -0,0 +1,19 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Runtime.InteropServices; + +namespace Microsoft.Win32.SafeHandles +{ + // Class of safe handle which uses only -1 as an invalid handle. + public abstract class SafeHandleMinusOneIsInvalid : SafeHandle + { + protected SafeHandleMinusOneIsInvalid(bool ownsHandle) : base(new IntPtr(-1), ownsHandle) + { + } + + public override bool IsInvalid => handle == new IntPtr(-1); + } +} |