Exemple #1
0
        private async Task EvaluateOutputAsync()
        {
            if (operators.Count == 0)
            {
                throw new ScopeParserException("Missing operator(s): " + GetRestOfExpression());
            }
            Operator @operator = operators.Pop();

            if (@operator.TypeValue == Operator.Type.Unary && output.Count >= 1)
            {
                AsyncOperand         asyncOperand = output.Pop();
                Stack <AsyncOperand> stack        = output;
                stack.Push(await @operator.TheFuncDelegateAsync(asyncOperand, asyncOperand));
                return;
            }
            if (@operator.TypeValue == Operator.Type.Binary && output.Count >= 2)
            {
                AsyncOperand         b     = output.Pop();
                AsyncOperand         a     = output.Pop();
                Stack <AsyncOperand> stack = output;
                stack.Push(await @operator.TheFuncDelegateAsync(a, b));
                return;
            }
            throw new ScopeParserException("Missing operand(s): " + GetRestOfExpression());
        }
Exemple #2
0
            public override async Task <int> CompareToAsync(AsyncOperand a)
            {
                object aValue = await a.Value().ConfigureAwait(false);

                if (aValue is string)
                {
                    return(((string)(await Value().ConfigureAwait(false))).CompareTo((string)aValue));
                }
                throw new ScopeParserException("Trying to compare two different types");
            }
Exemple #3
0
 public static AsyncOperand OrAsync(AsyncOperand a, AsyncOperand b)
 {
     return(new LazyOperand(async delegate
     {
         if (await a.ToBoolAsync().ConfigureAwait(false))
         {
             return new BoolOperand(true);
         }
         return (await b.ToBoolAsync().ConfigureAwait(false)) ? new BoolOperand(true) : new BoolOperand(false);
     }));
 }
Exemple #4
0
 public override async Task <int> CompareToAsync(AsyncOperand a)
 {
     return(await(await lazy.Value).CompareToAsync(a).ConfigureAwait(false));
 }
Exemple #5
0
 private void ParseOperand(AsyncOperand op)
 {
     output.Push(op);
 }
Exemple #6
0
 public override Task <int> CompareToAsync(AsyncOperand a)
 {
     throw new ScopeParserException(errorMessage);
 }
Exemple #7
0
 public static async Task <AsyncOperand> Not(AsyncOperand a)
 {
     return(new BoolOperand(!(await a.ToBoolAsync().ConfigureAwait(false))));
 }
Exemple #8
0
 public static AsyncOperand AndAsync(AsyncOperand a, AsyncOperand b)
 {
     return(new LazyOperand(async() => (await a.ToBoolAsync().ConfigureAwait(false) && await b.ToBoolAsync().ConfigureAwait(false)) ? new BoolOperand(true) : new BoolOperand(false)));
 }
Exemple #9
0
 public async Task <bool> EqualsAsync(AsyncOperand y)
 {
     return(await CompareToAsync(y).ConfigureAwait(false) == 0);
 }
Exemple #10
0
 public abstract Task <int> CompareToAsync(AsyncOperand a);