From: Wootak Date: Wed, 30 Jan 2019 08:18:20 +0000 (+0900) Subject: [Bluetooth] Add new API to destroy Gatt server (#690) X-Git-Tag: 5.5_M2~319 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d8854f186ebcd1371bba16c1afa31047d9f8fa22;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [Bluetooth] Add new API to destroy Gatt server (#690) * [Bluetooth] Add new API to destroy Gatt server --- diff --git a/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothGatt.cs b/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothGatt.cs index a60e18f..21c5056 100644 --- a/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothGatt.cs +++ b/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothGatt.cs @@ -26,10 +26,11 @@ namespace Tizen.Network.Bluetooth /// The Bluetooth GATT server. /// /// 3 - public class BluetoothGattServer + public class BluetoothGattServer : IDisposable { private static BluetoothGattServer _instance; private BluetoothGattServerImpl _impl; + private BluetoothGattServer() { _impl = new BluetoothGattServerImpl(); @@ -200,6 +201,38 @@ namespace Tizen.Network.Bluetooth { return _impl.GetHandle().IsInvalid == false; } + + /// + /// Destroys the current object. + /// + ~BluetoothGattServer() + { + Dispose(false); + } + + /// + /// Destroys the current object. + /// + /// 6 + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + /// + /// Releases all the resources currently used by this instance. + /// + /// true if the managed resources should be disposed, otherwise false. + /// 6 + protected virtual void Dispose(bool disposing) + { + if (disposing) + { + _impl?.GetHandle()?.Dispose(); + _instance = null; + } + } } ///