[Usb] Change internal Dispose functions from protected to internal
[platform/core/csapi/tizenfx.git] / src / Tizen.System.Usb / Usb / UsbConfiguration.cs
old mode 100644 (file)
new mode 100755 (executable)
index ba9abfb..dd4fc66
@@ -23,6 +23,7 @@ namespace Tizen.System.Usb
     /// <summary>
     /// Class to manage USB Configuration.
     /// </summary>
+    /// <since_tizen> 5 </since_tizen>
     public class UsbConfiguration : IDisposable
     {
         internal readonly Interop.UsbConfigHandle _handle;
@@ -38,6 +39,9 @@ namespace Tizen.System.Usb
         /// <summary>
         /// Checks if device is self-powered in given configuration.
         /// </summary>
+        /// <feature>http://tizen.org/feature/usb.host</feature>
+        /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
+        /// <since_tizen> 5 </since_tizen>
         public bool IsSelfPowered
         {
             get
@@ -50,6 +54,9 @@ namespace Tizen.System.Usb
         /// <summary>
         /// Checks if device in given configuration supports remote wakeup.
         /// </summary>
+        /// <feature>http://tizen.org/feature/usb.host</feature>
+        /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
+        /// <since_tizen> 5 </since_tizen>
         public bool SupportRemoteWakeup
         {
             get
@@ -62,6 +69,9 @@ namespace Tizen.System.Usb
         /// <summary>
         /// Gets maximum power required in given configuration, in mA.
         /// </summary>
+        /// <feature>http://tizen.org/feature/usb.host</feature>
+        /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
+        /// <since_tizen> 5 </since_tizen>
         public int MaximumPowerRequired
         {
             get
@@ -74,6 +84,9 @@ namespace Tizen.System.Usb
         /// <summary>
         /// Dictionary mapping interfaces Ids to interface instances for given configuration.
         /// </summary>
+        /// <feature>http://tizen.org/feature/usb.host</feature>
+        /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
+        /// <since_tizen> 5 </since_tizen>
         public IReadOnlyDictionary<int, UsbInterface> Interfaces
         {
             get
@@ -85,9 +98,9 @@ namespace Tizen.System.Usb
                     int count = Interop.NativeGet<int>(_handle.GetNumInterfaces);
                     for (int i = 0; i < count; ++i)
                     {
-                        Interop.UsbInterfaceHandle handle;
+                        IntPtr handle;
                         _handle.GetInterface(i, out handle);
-                        UsbInterface usbInterface = new UsbInterface(this, handle);
+                        UsbInterface usbInterface = new UsbInterface(this, new Interop.UsbInterfaceHandle(handle));
                         _interfaces.Add(usbInterface.Id, usbInterface);
                     }
                 }
@@ -98,11 +111,18 @@ namespace Tizen.System.Usb
         /// <summary>
         /// Configuration string.
         /// </summary>
+        /// <feature>http://tizen.org/feature/usb.host</feature>
+        /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
+        /// <exception cref="InvalidOperationException">
+        /// Throws exception if device is disconnected or not opened for operation or busy as its interfaces are currently claimed.
+        /// </exception>
+        /// <since_tizen> 5 </since_tizen>
         public string ConfigurationString
         {
             get
             {
                 ThrowIfDisposed();
+                _parent.ThrowIfDeviceNotOpened();
                 return Interop.DescriptorString(_handle.GetConfigStr);
             }
         }
@@ -110,13 +130,15 @@ namespace Tizen.System.Usb
         /// <summary>
         /// Set this configuration as active configuration for the device.
         /// </summary>
-        /// <exception cref="InvalidOperationException">
-        /// Throws exception if device is disconnected or not opened for operation or busy as its interfaces are currently claimed.
-        /// </exception>
+        /// <feature>http://tizen.org/feature/usb.host</feature>
+        /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
+        /// <exception cref="InvalidOperationException"> Throws exception if device is disconnected or not opened for operation. </exception>
+        /// <since_tizen> 5 </since_tizen>
         public void SetAsActive()
         {
             ThrowIfDisposed();
-            _handle.SetAsActive();
+            _parent.ThrowIfDeviceNotOpened();
+            _handle.SetAsActive().ThrowIfFailed("Failed to activate this configuration");
         }
 
         internal void ThrowIfDisposed()
@@ -125,10 +147,19 @@ namespace Tizen.System.Usb
             _parent.ThrowIfDisposed();
         }
 
+        internal void ThrowIfDeviceNotOpened()
+        {
+            _parent.ThrowIfDeviceNotOpened();
+        }
+
         #region IDisposable Support
         private bool disposedValue = false;
 
-        protected virtual void Dispose(bool disposing)
+        /// <summary>
+        /// Releases all resources used by the ConnectionProfile.
+        /// It should be called after finished using of the object.</summary>
+        /// <since_tizen> 5 </since_tizen>
+        internal virtual void Dispose(bool disposing)
         {
             if (!disposedValue)
             {
@@ -137,11 +168,19 @@ namespace Tizen.System.Usb
             }
         }
 
+        /// <summary>
+        /// Finalizes an instance of the UsbConfiguration class.
+        /// </summary>
+        /// <since_tizen> 5 </since_tizen>
         ~UsbConfiguration()
         {
             Dispose(false);
         }
 
+        /// <summary>
+        /// Releases all resources used by the ConnectionProfile.
+        /// It should be called after finished using of the object.</summary>
+        /// <since_tizen> 5 </since_tizen>
         public void Dispose()
         {
             Dispose(true);
@@ -149,4 +188,4 @@ namespace Tizen.System.Usb
         }
         #endregion
     }
-}
\ No newline at end of file
+}