示例#1
0
        /// <inheritdoc />
        protected override async Task <Result <Unit, IError> > Run(
            IStateMonad stateMonad,
            CancellationToken cancellationToken)
        {
            var left = await Left.Run(stateMonad, cancellationToken);

            if (left.IsFailure)
            {
                return(left.ConvertFailure <Unit>());
            }

            var right = await Right.Run(stateMonad, cancellationToken);

            if (right.IsFailure)
            {
                return(right.ConvertFailure <Unit>());
            }

            var r = left.Value is not null && left.Value.Equals(right.Value);

            if (r)
            {
                return(Unit.Default);
            }

            var lString = await SerializationMethods.GetStringAsync(left.Value);

            var rString = await SerializationMethods.GetStringAsync(right.Value);

            var error = ErrorCode.AssertionFailed
                        .ToErrorBuilder($"Expected {lString} to equal {rString}")
                        .WithLocation(this);

            return(Result.Failure <Unit, IError>(error));
        }
示例#2
0
文件: Log.cs 项目: reductech/Core
        /// <inheritdoc />
        protected override async Task <Result <Unit, IError> > Run(
            IStateMonad stateMonad,
            CancellationToken cancellationToken)
        {
            var r = await Value.Run(stateMonad, cancellationToken);

            if (r.IsFailure)
            {
                return(r.ConvertFailure <Unit>());
            }

            var stringToPrint = await SerializationMethods.GetStringAsync(r.Value);

            stateMonad.Log(LogLevel.Information, stringToPrint, this);

            return(Unit.Default);
        }
示例#3
0
        /// <inheritdoc />
        protected override async Task <Result <Unit, IError> > Run(
            IStateMonad stateMonad,
            CancellationToken cancellationToken)
        {
            var r = await Value.Run(stateMonad, cancellationToken);

            if (r.IsFailure)
            {
                return(r.ConvertFailure <Unit>());
            }

            string stringToPrint = await SerializationMethods.GetStringAsync(r.Value);

            stateMonad.ExternalContext.Console.WriteLine(stringToPrint);

            return(Unit.Default);
        }
示例#4
0
        /// <inheritdoc />
        protected override async Task <Result <StringStream, IError> > Run(
            IStateMonad stateMonad,
            CancellationToken cancellationToken)
        {
            var sb = new StringBuilder();

            foreach (var step in Strings)
            {
                var o = await step.Run <object>(stateMonad, cancellationToken);

                if (o.IsFailure)
                {
                    return(o.ConvertFailure <StringStream>());
                }

                var s = await SerializationMethods.GetStringAsync(o.Value);

                sb.Append(s);
            }

            StringStream ss = sb.ToString();

            return(ss);
        }