/// <summary> /// Initializes a new instance of the <see cref="CommandCompletedEventArgs"/> class. /// </summary> /// <param name="requestId">The request id for each command.</param> /// <param name="result">The result of commands.</param> /// <exception cref="ArgumentException"><paramref name="result"/> is not vailid.</exception> /// <exception cref="ArgumentNullException"><paramref name="requestId"/> is null.</exception> /// <since_tizen> 5 </since_tizen> internal CommandCompletedEventArgs(string requestId, MediaControllerError result) { ValidationUtil.ValidateEnum(typeof(MediaControllerError), result, nameof(result)); RequestId = requestId ?? throw new ArgumentNullException(nameof(requestId)); Result = result; }
internal static void ThrowIfError(this MediaControllerError error, string message) { if (error == MediaControllerError.None) { return; } string msg = $"{ (message ?? "Operation failed") } : { error.ToString() }."; switch (error) { case MediaControllerError.InvalidParameter: throw new ArgumentException(msg); // User should not throw System.OutOfMemoryException itself. case MediaControllerError.OutOfMemory: case MediaControllerError.InvalidOperation: throw new InvalidOperationException(msg); case MediaControllerError.NoSpaceOnDevice: throw new IOException($"Not enough storage : {msg}"); case MediaControllerError.PermissionDenied: throw new UnauthorizedAccessException(msg); } throw new InvalidOperationException($"Unknown error({error}) : {message}"); }
internal static void ThrowIfError(this MediaControllerError error, string errorMessage) { if (error == MediaControllerError.None) { return; } switch (error) { case MediaControllerError.InvalidParameter: throw new ArgumentException(errorMessage); case MediaControllerError.OutOfMemory: throw new OutOfMemoryException(errorMessage); case MediaControllerError.InvalidOperation: throw new InvalidOperationException(errorMessage); case MediaControllerError.NoSpaceOnDevice: throw new IOException($"Not enough storage : {errorMessage}"); case MediaControllerError.PermissionDenied: throw new UnauthorizedAccessException(errorMessage); } throw new InvalidOperationException($"Unknown error({error}) : {errorMessage}"); }
internal void RaiseCommandCompletedEvent(string requestId, MediaControllerError result, IntPtr bundleHandle) { if (bundleHandle != IntPtr.Zero) { CommandCompleted?.Invoke(this, new CommandCompletedEventArgs(requestId, result, new Bundle(new SafeBundleHandle(bundleHandle, true)))); } else { CommandCompleted?.Invoke(this, new CommandCompletedEventArgs(requestId, result)); } }
/// <summary> /// Initializes a new instance of the <see cref="CommandCompletedEventArgs"/> class with extra data. /// </summary> /// <param name="requestId">The request id for each command.</param> /// <param name="result">The result of commands.</param> /// <param name="bundle">The extra data.</param> /// <since_tizen> 5 </since_tizen> internal CommandCompletedEventArgs(string requestId, MediaControllerError result, Bundle bundle) : this(requestId, result) { Bundle = bundle; }