// // TakeControlCommandExtensions.cs // // Copyright (c) František Boháček. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; using System.Threading; using System.Threading.Tasks; using NosSmooth.Core.Commands.Control; using Remora.Results; namespace NosSmooth.Core.Extensions; /// /// Extension methods for . /// public static class TakeControlCommandExtensions { /// /// Create a take control command base on a command that supports taking control over. /// /// The command implementing take control to copy. /// The group of the new take control. /// The callback to be called when control is granted. /// The callback to be called if the operation was cancelled and the control was revoked. /// The copied take control command. public static TakeControlCommand CreateTakeControl ( this ITakeControlCommand takeControlCommand, string group, Func> handleCallback, Func> cancellationCallback ) { return new TakeControlCommand ( handleCallback, cancellationCallback, group, takeControlCommand.CanBeCancelledByAnother, takeControlCommand.WaitForCancellation, takeControlCommand.AllowUserCancel, takeControlCommand.CancelOnMapChange ); } }