private ILimitValueSource CreateValueSourceFrom(ExpanderCountNode countNode) { Debug.Assert(countNode.IsLiteral || countNode.IsCounterReference); if (countNode.IsLiteral) { return(new LiteralLimitValueSource(countNode.Literal)); } var x = this.counters.First(counter => counter.CounterName == countNode.CounterReference.CounterName); return(new CounterLimitValueSource(x)); }
private ILimitValueSource CreateValueSourceFrom(ExpanderCountNode countNode) { Debug.Assert(countNode.IsLiteral || countNode.IsCounterReference || countNode.IsFunctionInvocation); if (countNode.IsLiteral) { return(new LiteralLimitValueSource(countNode.Literal)); } if (countNode.IsFunctionInvocation) { var functionInvocationContext = new FunctionInvocationContext(countNode.FunctionInvocation, Model); return(new FunctionInvocationValueSource(functionInvocationContext)); } var theCounter = Counters.First(counter => counter.CounterName == countNode.CounterReference.CounterName); return(new CounterLimitValueSource(theCounter)); }
private ILimitValueSource CreateValueSourceFrom(ExpanderCountNode countNode) { Debug.Assert(countNode.IsLiteral || countNode.IsCounterReference || countNode.IsFunctionInvocation); switch (countNode.InnerExpression) { case IntegerLiteralNode literalNode: return(new LiteralLimitValueSource(literalNode)); case FunctionInvocationNode functionInvocationNode: var functionInvocationContext = new FunctionInvocationContext(functionInvocationNode, Model); return(new FunctionInvocationValueSource(functionInvocationContext)); case CounterReferenceNode counterReferenceNode: var counterReference = Counters.First(counter => counter.CounterName == counterReferenceNode.CounterName); return(new CounterLimitValueSource(counterReference)); default: throw new NotImplementedException("Unknown count expression."); } }