private static Try <IFilterExpression> InstantiateFilter(ITemplateContext templateContext, FilterSymbol filterSymbol) { var filterType = templateContext.SymbolTableStack.LookupFilterType(filterSymbol.Name); // if (filterType == null) // { // return null; // } var expressionConstants = filterSymbol.Args.Select(x => Eval(x, templateContext)).ToList(); if (expressionConstants.Any(x => x.IsError)) { //return null; // eval-ing a constant failed. TODO: Is this actually possible? //throw new Exception(String.Join("," ,expressionConstants.Where(x => x.IsError).Select(x => x.ErrorResult.Message))); return (new Failure <IFilterExpression>( new Exception(String.Join(",", expressionConstants.Where(x => x.IsError).Select(x => x.ErrorResult.Message))))); } return(FilterFactory.InstantiateFilter(filterSymbol.Name, filterType, expressionConstants.Select(x => x.SuccessResult))); }
public void AddFilterSymbolToLastExpression(FilterSymbol filter) { _lastExpression.Data.AddFilterSymbol(filter); }