///------------------------------------------------------------------------------------------------- /// <summary> Unplug target device. </summary> /// /// <remarks> Benjamin "Nefarius" Höglinger, 12.06.2017. </remarks> /// /// <exception cref="VigemBusNotFoundException"> Thrown when a Vigem Bus Not Found /// error condition occurs. /// </exception> /// <exception cref="VigemTargetUninitializedException"> Thrown when a Vigem Target /// Uninitialized error condition occurs. /// </exception> /// <exception cref="VigemTargetNotPluggedInException"> Thrown when a Vigem Target Not /// Plugged In error condition occurs. /// </exception> /// <exception cref="VigemRemovalFailedException"> Thrown when a Vigem Removal Failed /// error condition occurs. /// </exception> ///------------------------------------------------------------------------------------------------- protected void UnPlug() { var error = ViGemUm.vigem_target_unplug(ref Target); // ReSharper disable once SwitchStatementMissingSomeCases switch (error) { case ViGemUm.VigemError.VigemErrorNone: break; case ViGemUm.VigemError.VigemErrorBusNotFound: throw new VigemBusNotFoundException( StringResource.VigemBusNotFoundException); case ViGemUm.VigemError.VigemErrorTargetUninitialized: throw new VigemTargetUninitializedException( StringResource.VigemTargetUninitializedException); case ViGemUm.VigemError.VigemErrorTargetNotPluggedIn: throw new VigemTargetNotPluggedInException( StringResource.VigemTargetNotPluggedInException); case ViGemUm.VigemError.VigemErrorRemovalFailed: throw new VigemRemovalFailedException( StringResource.VigemRemovalFailedException); } }
private bool _disposedValue; // To detect redundant calls protected virtual void Dispose(bool disposing) { if (!_disposedValue) { if (disposing) { ViGemUm.vigem_target_unplug(ref Target); } // TODO: free unmanaged resources (unmanaged objects) and override a finalizer below. // TODO: set large fields to null. _disposedValue = true; } }
public void UnPlug() { ViGemUm.vigem_target_unplug(ref _target); }