using ScenarioFlow;
using ScenarioFlow.Scripts.SFText;
using ScenarioFlow.Tasks;
using System;
using System.Threading;

namespace HowToWriteSFText
{
	public class CancellationTokenDecoder : IReflectable
	{
		private readonly ICancellationTokenDecoder cancellationTokenDecoder;

		public CancellationTokenDecoder(ICancellationTokenDecoder cancellationTokenDecoder)
		{
			this.cancellationTokenDecoder = cancellationTokenDecoder ?? throw new ArgumentNullException(nameof(cancellationTokenDecoder));
		}

		[DecoderMethod]
		[Category("Asynchronous")]
		[Description("Decoder for 'CancellationToken'")]
		public CancellationToken GetCancellationToken(string tokenCode)
		{
			return cancellationTokenDecoder.Decode(tokenCode);
		}
	}
}