/// <summary>
/// Class to manage USB Configuration.
/// </summary>
+ /// <since_tizen> 5 </since_tizen>
public class UsbConfiguration : IDisposable
{
internal readonly Interop.UsbConfigHandle _handle;
/// <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
/// <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
/// <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
/// <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
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);
}
}
/// <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);
}
}
/// <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()
_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)
{
}
}
+ /// <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);
}
#endregion
}
-}
\ No newline at end of file
+}