Release 4.0.0-preview1-00285
[platform/core/csapi/tizenfx.git] / src / Tizen.Network.Bluetooth / Tizen.Network.Bluetooth / BluetoothAdapter.cs
index ee9aca5..8566810 100644 (file)
@@ -20,7 +20,7 @@ using System.Collections.Generic;
 namespace Tizen.Network.Bluetooth
 {
     /// <summary>
-    /// This class is used to control the Bluetooth adapter and get the list of bonded devices.<br>
+    /// This class is used to control the Bluetooth adapter and get the list of bonded devices.<br/>
     /// The BluetoothAdapter class is used to discover neighbouring bluetooth devices.
     /// </summary>
     /// <privilege> http://tizen.org/privilege/bluetooth </privilege>
@@ -29,13 +29,20 @@ namespace Tizen.Network.Bluetooth
         /// <summary>
         /// A property to check whether the Bluetooth is enabled.
         /// </summary>
-        /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
-        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth is not enabled.</exception>
+        /// <exception cref="NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
+        /// <exception cref="InvalidOperationException">Thrown when the Bluetooth is not enabled.</exception>
         static public bool IsBluetoothEnabled
         {
             get
             {
-                return BluetoothAdapterImpl.Instance.IsBluetoothEnabled;
+                try
+                {
+                    return BluetoothAdapterImpl.Instance.IsBluetoothEnabled;
+                }
+                catch (TypeInitializationException e)
+                {
+                    throw e.InnerException;
+                }
             }
         }
 
@@ -45,8 +52,8 @@ namespace Tizen.Network.Bluetooth
         /// <remarks>
         /// The Bluetooth must be enabled.
         /// </remarks>
-        /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
-        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth is not enabled.</exception>
+        /// <exception cref="NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
+        /// <exception cref="InvalidOperationException">Thrown when the Bluetooth is not enabled.</exception>
         static public string Address
         {
             get
@@ -68,8 +75,8 @@ namespace Tizen.Network.Bluetooth
         /// <remarks>
         /// The Bluetooth must be enabled.
         /// </remarks>
-        /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
-        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth is not enabled.</exception>
+        /// <exception cref="NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
+        /// <exception cref="InvalidOperationException">Thrown when the Bluetooth is not enabled.</exception>
         static public string Name
         {
             get
@@ -85,7 +92,14 @@ namespace Tizen.Network.Bluetooth
             }
             set
             {
-                BluetoothAdapterImpl.Instance.Name = value;
+                try
+                {
+                    BluetoothAdapterImpl.Instance.Name = value;
+                }
+                catch (TypeInitializationException e)
+                {
+                    throw e.InnerException;
+                }
             }
         }
 
@@ -95,8 +109,8 @@ namespace Tizen.Network.Bluetooth
         /// <remarks>
         /// The Bluetooth must be enabled.
         /// </remarks>
-        /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
-        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth is not enabled.</exception>
+        /// <exception cref="NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
+        /// <exception cref="InvalidOperationException">Thrown when the Bluetooth is not enabled.</exception>
         static public VisibilityMode Visibility
         {
             get
@@ -118,8 +132,8 @@ namespace Tizen.Network.Bluetooth
         /// <remarks>
         /// The Bluetooth must be enabled.
         /// </remarks>
-        /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
-        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth is not enabled.</exception>
+        /// <exception cref="NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
+        /// <exception cref="InvalidOperationException">Thrown when the Bluetooth is not enabled.</exception>
         static public bool IsDiscoveryInProgress
         {
             get
@@ -141,8 +155,8 @@ namespace Tizen.Network.Bluetooth
         /// <remarks>
         /// The Bluetooth must be enabled.
         /// </remarks>
-        /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
-        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth is not enabled.</exception>
+        /// <exception cref="NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
+        /// <exception cref="InvalidOperationException">Thrown when the Bluetooth is not enabled.</exception>
         static public int RemainingTimeAsVisible
         {
             get
@@ -161,89 +175,186 @@ namespace Tizen.Network.Bluetooth
         /// <summary>
         /// The StateChanged event is raised when the Bluetooth adapter state is changed.
         /// </summary>
+        /// <exception cref="NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
+        /// <exception cref="InvalidOperationException">Thrown when the Bluetooth is not enabled.</exception>
         static public event EventHandler<StateChangedEventArgs> StateChanged
         {
             add
             {
-                BluetoothAdapterImpl.Instance.StateChanged += value;
+                try
+                {
+                    BluetoothAdapterImpl.Instance.StateChanged += value;
+                }
+                catch (TypeInitializationException e)
+                {
+                    throw e.InnerException;
+                }
             }
             remove
             {
-                BluetoothAdapterImpl.Instance.StateChanged -= value;
+                try
+                {
+                    BluetoothAdapterImpl.Instance.StateChanged -= value;
+                }
+                catch (TypeInitializationException e)
+                {
+                    throw e.InnerException;
+                }
             }
         }
 
         /// <summary>
         /// The NameChanged event is raised when the Bluetooth adapter name is changed.
         /// </summary>
+        /// <exception cref="NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
+        /// <exception cref="InvalidOperationException">Thrown when the Bluetooth is not enabled.</exception>
         static public event EventHandler<NameChangedEventArgs> NameChanged
         {
             add
             {
-                BluetoothAdapterImpl.Instance.NameChanged += value;
+                try
+                {
+                    BluetoothAdapterImpl.Instance.NameChanged += value;
+                }
+                catch (TypeInitializationException e)
+                {
+                    throw e.InnerException;
+                }
             }
             remove
             {
-                BluetoothAdapterImpl.Instance.NameChanged -= value;
+                try
+                {
+                    BluetoothAdapterImpl.Instance.NameChanged -= value;
+                }
+                catch (TypeInitializationException e)
+                {
+                    throw e.InnerException;
+                }
             }
         }
 
         /// <summary>
         /// The VisibilityModeChanged event is raised when the Bluetooth adapter visibility mode is changed.
         /// </summary>
+        /// <exception cref="NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
+        /// <exception cref="InvalidOperationException">Thrown when the Bluetooth is not enabled.</exception>
         static public event EventHandler<VisibilityModeChangedEventArgs> VisibilityModeChanged
         {
             add
             {
-                BluetoothAdapterImpl.Instance.VisibilityModeChanged += value;
+                try
+                {
+                    BluetoothAdapterImpl.Instance.VisibilityModeChanged += value;
+                }
+                catch (TypeInitializationException e)
+                {
+                    throw e.InnerException;
+                }
             }
             remove
             {
-                BluetoothAdapterImpl.Instance.VisibilityModeChanged -= value;
+                try
+                {
+                    BluetoothAdapterImpl.Instance.VisibilityModeChanged -= value;
+                }
+                catch (TypeInitializationException e)
+                {
+                    throw e.InnerException;
+                }
             }
         }
 
         /// <summary>
         /// The VisibilityDurationChanged event is raised very second until the visibility mode is changed to NonDiscoverable.
         /// </summary>
+        /// <exception cref="NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
+        /// <exception cref="InvalidOperationException">Thrown when the Bluetooth is not enabled.</exception>
         static public event EventHandler<VisibilityDurationChangedEventArgs> VisibilityDurationChanged
         {
             add
             {
-                BluetoothAdapterImpl.Instance.VisibilityDurationChanged += value;
+                try
+                {
+                    BluetoothAdapterImpl.Instance.VisibilityDurationChanged += value;
+                }
+                catch (TypeInitializationException e)
+                {
+                    throw e.InnerException;
+                }
             }
             remove
             {
-                BluetoothAdapterImpl.Instance.VisibilityDurationChanged -= value;
+                try
+                {
+                    BluetoothAdapterImpl.Instance.VisibilityDurationChanged -= value;
+                }
+                catch (TypeInitializationException e)
+                {
+                    throw e.InnerException;
+                }
             }
         }
 
         /// <summary>
         /// The DiscoveryStateChanged event is raised when the device discovery state is changed.
         /// </summary>
+        /// <exception cref="NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
+        /// <exception cref="InvalidOperationException">Thrown when the Bluetooth is not enabled.</exception>
         static public event EventHandler<DiscoveryStateChangedEventArgs> DiscoveryStateChanged
         {
             add
             {
-                BluetoothAdapterImpl.Instance.DiscoveryStateChanged += value;
+                try
+                {
+                    BluetoothAdapterImpl.Instance.DiscoveryStateChanged += value;
+                }
+                catch (TypeInitializationException e)
+                {
+                    throw e.InnerException;
+                }
             }
             remove
             {
-                BluetoothAdapterImpl.Instance.DiscoveryStateChanged -= value;
+                try
+                {
+                    BluetoothAdapterImpl.Instance.DiscoveryStateChanged -= value;
+                }
+                catch (TypeInitializationException e)
+                {
+                    throw e.InnerException;
+                }
             }
         }
 
         /// <summary>
         /// This event is called when the LE scan result is obtained.
         /// </summary>
+        /// <exception cref="NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
+        /// <exception cref="InvalidOperationException">Thrown when the Bluetooth is not enabled.</exception>
         static public event EventHandler<AdapterLeScanResultChangedEventArgs> ScanResultChanged
         {
             add
             {
-                BluetoothLeImplAdapter.Instance.AdapterLeScanResultChanged += value;
+                try
+                {
+                    BluetoothLeImplAdapter.Instance.AdapterLeScanResultChanged += value;
+                }
+                catch (TypeInitializationException e)
+                {
+                    throw e.InnerException;
+                }
             }
-            remove {
-                BluetoothLeImplAdapter.Instance.AdapterLeScanResultChanged -= value;
+            remove
+            {
+                try
+                {
+                    BluetoothLeImplAdapter.Instance.AdapterLeScanResultChanged -= value;
+                }
+                catch (TypeInitializationException e)
+                {
+                    throw e.InnerException;
+                }
             }
         }
 
@@ -254,8 +365,8 @@ namespace Tizen.Network.Bluetooth
         /// The Bluetooth must be enabled and the device discovery process can be stopped by StopDiscovery().
         /// If this succeeds, the DiscoveryStateChanged event will be invoked.
         /// </remarks>
-        /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
-        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth is not enabled
+        /// <exception cref="NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
+        /// <exception cref="InvalidOperationException">Thrown when the Bluetooth is not enabled
         /// or the start discovery fails.</exception>
         static public void StartDiscovery()
         {
@@ -272,8 +383,8 @@ namespace Tizen.Network.Bluetooth
         /// The device discovery process must be in progress with StartDiscovery().
         /// If this succeeds, the DiscoveryStateChanged event will be invoked.
         /// </remarks>
-        /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
-        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth is not enabled or 
+        /// <exception cref="NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
+        /// <exception cref="InvalidOperationException">Thrown when the Bluetooth is not enabled or 
         /// the discovery process is not is progress. </exception>
         static public void StopDiscovery()
         {
@@ -290,8 +401,8 @@ namespace Tizen.Network.Bluetooth
         /// The Bluetooth must be enabled.
         /// </remarks>
         /// <returns> The list of the bonded BluetoothDeviceInfo objects.</returns>
-        /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
-        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth is not enabled
+        /// <exception cref="NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
+        /// <exception cref="InvalidOperationException">Thrown when the Bluetooth is not enabled
         /// or reading the Bonded devices list is failed.</exception>
         static public IEnumerable<BluetoothDevice> GetBondedDevices()
         {
@@ -312,8 +423,8 @@ namespace Tizen.Network.Bluetooth
         /// The Bluetooth must be enabled.
         /// </remarks>
         /// <returns> Information of the bonded BluetoothDeviceInfo object.</returns>
-        /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
-        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth is not enabled
+        /// <exception cref="NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
+        /// <exception cref="InvalidOperationException">Thrown when the Bluetooth is not enabled
         /// or reading the bonded device information fails.</exception>
         static public BluetoothDevice GetBondedDevice(string address)
         {
@@ -332,11 +443,18 @@ namespace Tizen.Network.Bluetooth
         /// </summary>
         /// <returns><c>true</c> if the specified serviceUuid is used, otherwise <c>false</c>.</returns>
         /// <param name="serviceUuid">The UUID of Service.</param>
-        /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
-        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth is not enabled.</exception>
+        /// <exception cref="NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
+        /// <exception cref="InvalidOperationException">Thrown when the Bluetooth is not enabled.</exception>
         static public bool IsServiceUsed(string serviceUuid)
         {
-            return BluetoothAdapterImpl.Instance.IsServiceUsed(serviceUuid);
+            try
+            {
+                return BluetoothAdapterImpl.Instance.IsServiceUsed(serviceUuid);
+            }
+            catch (TypeInitializationException e)
+            {
+                throw e.InnerException;
+            }
         }
 
         /// <summary>
@@ -346,8 +464,8 @@ namespace Tizen.Network.Bluetooth
         /// The Bluetooth must be enabled.
         /// </remarks>
         /// <returns>The BluetoothOobData object.</returns>
-        /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
-        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth is not enabled
+        /// <exception cref="NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
+        /// <exception cref="InvalidOperationException">Thrown when the Bluetooth is not enabled
         /// or the read OObData procedure is failed.</exception>
         static public BluetoothOobData GetLocalOobData()
         {
@@ -369,8 +487,8 @@ namespace Tizen.Network.Bluetooth
         /// </remarks>
         /// <param name="address">The remote device address.</param>
         /// <param name="oobData">The BluetoothOobData object.</param>
-        /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
-        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth is not enabled
+        /// <exception cref="NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
+        /// <exception cref="InvalidOperationException">Thrown when the Bluetooth is not enabled
         /// or the set OobData procedure is failed.</exception>
         static public void SetRemoteOobData(string address, BluetoothOobData oobData)
         {
@@ -387,8 +505,8 @@ namespace Tizen.Network.Bluetooth
         /// The Bluetooth must be enabled.
         /// </remarks>
         /// <param name="address">The remote device address.</param>
-        /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
-        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth is not enabled.
+        /// <exception cref="NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
+        /// <exception cref="InvalidOperationException">Thrown when the Bluetooth is not enabled.
         /// or if the Remove Oobdata procedure is failed.</exception>
         static public void RemoveRemoteOobData(string address)
         {
@@ -404,8 +522,8 @@ namespace Tizen.Network.Bluetooth
         /// <remarks>
         /// The Bluetooth must be enabled.
         /// </remarks>The result of the operation StartLeScan.
-        /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth LE is not supported.</exception>
-        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth LE is not enabled
+        /// <exception cref="NotSupportedException">Thrown when the Bluetooth LE is not supported.</exception>
+        /// <exception cref="InvalidOperationException">Thrown when the Bluetooth LE is not enabled
         /// or the Start LE scan is failed.</exception>
         static public void StartLeScan()
         {
@@ -430,8 +548,8 @@ namespace Tizen.Network.Bluetooth
         /// <remarks>
         /// The Bluetooth must be enabled.
         /// </remarks>The result of the operation stopLescan.
-        /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth LE is not supported.</exception>
-        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth LE is not enabled
+        /// <exception cref="NotSupportedException">Thrown when the Bluetooth LE is not supported.</exception>
+        /// <exception cref="InvalidOperationException">Thrown when the Bluetooth LE is not enabled
         /// or the Stop LE scan is failed.</exception>
         static public void StopLeScan()
         {
@@ -470,8 +588,8 @@ namespace Tizen.Network.Bluetooth
         /// </remarks>
         /// <returns>The BluetoothServerSocket instance.</returns>
         /// <param name="serviceUuid">The UUID of service to provide.</param>
-        /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
-        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth is not enabled
+        /// <exception cref="NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
+        /// <exception cref="InvalidOperationException">Thrown when the Bluetooth is not enabled
         /// or the socket create error occurs.</exception>
         static public BluetoothServerSocket CreateServerSocket(string serviceUuid)
         {
@@ -492,8 +610,8 @@ namespace Tizen.Network.Bluetooth
         /// The socket must be created with CreateServerSocket(). The ConnectionStateChanged event is raised after this API is called.
         /// </remarks>
         /// <param name="socket">The server socket instance is created using CreateServerSocket().</param>
-        /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
-        /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth is not enabled
+        /// <exception cref="NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
+        /// <exception cref="InvalidOperationException">Thrown when the Bluetooth is not enabled
         /// or the socket destroy error occurs.</exception>
         static public void DestroyServerSocket(BluetoothServerSocket socket)
         {