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()); }
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"); }
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); })); }
public override async Task <int> CompareToAsync(AsyncOperand a) { return(await(await lazy.Value).CompareToAsync(a).ConfigureAwait(false)); }
private void ParseOperand(AsyncOperand op) { output.Push(op); }
public override Task <int> CompareToAsync(AsyncOperand a) { throw new ScopeParserException(errorMessage); }
public static async Task <AsyncOperand> Not(AsyncOperand a) { return(new BoolOperand(!(await a.ToBoolAsync().ConfigureAwait(false)))); }
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))); }
public async Task <bool> EqualsAsync(AsyncOperand y) { return(await CompareToAsync(y).ConfigureAwait(false) == 0); }
public abstract Task <int> CompareToAsync(AsyncOperand a);