예제 #1
0
        /// <inheritdoc />
        protected override async Task <Result <bool, IError> > Run(
            IStateMonad stateMonad,
            CancellationToken cancellationToken)
        {
            var superstringResult = await String.Run(stateMonad, cancellationToken)
                                    .Map(async x => await x.GetStringAsync());

            if (superstringResult.IsFailure)
            {
                return(superstringResult.ConvertFailure <bool>());
            }

            var substringResult = await Substring.Run(stateMonad, cancellationToken)
                                  .Map(async x => await x.GetStringAsync());

            if (substringResult.IsFailure)
            {
                return(substringResult.ConvertFailure <bool>());
            }

            var ignoreCaseResult = await IgnoreCase.Run(stateMonad, cancellationToken);

            if (ignoreCaseResult.IsFailure)
            {
                return(ignoreCaseResult.ConvertFailure <bool>());
            }

            var comparison = ignoreCaseResult.Value
            ? StringComparison.OrdinalIgnoreCase
            : StringComparison.Ordinal;

            var r = superstringResult.Value.Contains(substringResult.Value, comparison);

            return(r);
        }