Exemplo n.º 1
0
        public override LuaValue Execute(LuaTable enviroment, out bool isBreak)
        {
            LuaValue condition = Condition.Evaluate(enviroment);

            if (condition.GetBooleanValue() == true)
            {
                return(ThenBlock.Execute(enviroment, out isBreak));
            }
            else
            {
                foreach (ElseifBlock elseifBlock in ElseifBlocks)
                {
                    condition = elseifBlock.Condition.Evaluate(enviroment);

                    if (condition.GetBooleanValue() == true)
                    {
                        return(elseifBlock.ThenBlock.Execute(enviroment, out isBreak));
                    }
                }

                if (ElseBlock != null)
                {
                    return(ElseBlock.Execute(enviroment, out isBreak));
                }
            }

            isBreak = false;
            return(null);
        }
Exemplo n.º 2
0
        public override void AcceptVisitor(StatementVisitor visitor)
        {
            visitor.VisitIfStatement(this);

            if (Condition != null)
            {
                Condition.AcceptVisitor(visitor);
            }

            if (ThenBlock != null)
            {
                ThenBlock.AcceptVisitor(visitor);
            }

            if (ElseBlock != null)
            {
                ElseBlock.AcceptVisitor(visitor);
            }
        }
Exemplo n.º 3
0
        protected override bool OnExecute(GameState state, Hero hero)
        {
            if (Condition == null)
            {
                return(true);
            }

            if (Condition.Evaluate(state, hero))
            {
                if (ThenBlock != null)
                {
                    return(ThenBlock.Execute(state, hero));
                }
            }
            else if (ElseBlock != null)
            {
                return(ElseBlock.Execute(state, hero));
            }

            return(true);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Check for errors.
        /// </summary>
        /// <typeparam name="TInput">Input type</typeparam>
        /// <param name="thenBlock">Then block</param>
        /// <param name="errorCode">Error code</param>
        /// <param name="errorMessage">Error message</param>
        /// <returns>Result of checking.</returns>
        public static ThenBlock <InvalidDeriveOperationException, InvalidDeriveOperationException> AndAssertErrorDetail <TInput>(this ThenBlock <TInput, InvalidDeriveOperationException> thenBlock, string errorCode, string errorMessage)
        {
            return(thenBlock.And($"Check error with code {errorCode}", error =>
            {
                if (error == null)
                {
                    AssertErrorDetail(null, errorCode, errorMessage);
                }
                else if (error.Details == null)
                {
                    new FactFactoryException(null);
                }

                new FactFactoryException(error.Details.Select(detail => (ErrorDetail)detail).ToList()).AssertErrorDetail(errorCode, errorMessage);
            }));
        }
 /// <summary>
 /// Check error code and reason.
 /// </summary>
 /// <param name="thenBlock"></param>
 /// <param name="code"></param>
 /// <param name="reason"></param>
 /// <returns></returns>
 public static ThenBlock <GetcuReoneException, GetcuReoneException> AndAssertError <TIn>(this ThenBlock <TIn, GetcuReoneException> thenBlock, string code, string reason)
 {
     return(thenBlock.And($"Check error. Code <{code}>, Reason <{reason}>.",
                          error => AssertError(error, code, reason)));
 }
Exemplo n.º 6
0
 public static void RunWindow <TIn, TOut>(this ThenBlock <TIn, TOut> then, int maxWaitTime)
 => then.Run <TestWindow>(window => window.mainFrame, maxWaitTime);