private static SwitchContext <TCapture> CreateContext <TCapture>(TCapture capture, CancellationTokenSource cancellationTokenSource) { var cancellationToken = cancellationTokenSource != null ? cancellationTokenSource.Token : CancellationToken.None; var context = new SwitchContext <TCapture>(capture, cancellationToken); return(context); }
public static SwitchCaseCondition <MochiUnit> UnsafeCase <TCapture>(this SwitchContext <TCapture> _, Task task) => UnsafeCase(_, (MochiTask <MochiUnit>)task.ToMochiTask());
public static SwitchCaseCondition <MochiUnit> UnsafeDefault <TCapture>(this SwitchContext <TCapture> _) => new SwitchCaseCondition <MochiUnit>(true, new Awaiter <MochiUnit>(default(MochiUnit)));
public static SwitchCaseCondition <T> UnsafeCase <TCapture, T>(this SwitchContext <TCapture> _, MochiTask <T> task) => new SwitchCaseCondition <T>(true, task.GetAwaiter());
public static SwitchCaseCondition <T> UnsafeCase <TCapture, T>(this SwitchContext <TCapture> _, Task <T> task) => UnsafeCase(_, task.ToMochiTask());