Release 4.0.0-preview1-00051
[platform/core/csapi/tizenfx.git] / src / Tizen.Convergence / Interop / Interop.Common.cs
1 // Copyright 2016 by Samsung Electronics, Inc.,
2 //
3 // This software is the confidential and proprietary information
4 // of Samsung Electronics, Inc. ("Confidential Information"). You
5 // shall not disclose such Confidential Information and shall use
6 // it only in accordance with the terms of the license agreement
7 // you entered into with Samsung.
8
9 using System;
10 using System.Runtime.InteropServices;
11
12 internal static partial class Interop
13 {
14     internal abstract class TizenSafeHandle : SafeHandle
15     {
16         public abstract void Destroy();
17
18         public TizenSafeHandle() : base(IntPtr.Zero, true)
19         {
20         }
21
22         public TizenSafeHandle(IntPtr handle) : base(handle, true)
23         {
24         }
25
26         public override bool IsInvalid
27         {
28             get
29             {
30                 return handle == IntPtr.Zero;
31             }
32         }
33
34         protected override bool ReleaseHandle()
35         {
36             Destroy();
37             SetHandle(IntPtr.Zero);
38             return true;
39         }
40     }
41 }