protected override EvalResult EvalImpl(ScmEnvironment env) { if (!_clauses.Any()) { return(new SelfEvaluatingExpression(false).ToResult()); } else { foreach (var clause in _clauses) { var tokens = _tokenizer.Parse(_tokenizer.Strip(clause.Value)).ToArray(); if (tokens[0].Value == "else") { return(_factory.Create(tokens[1].Value).Eval(env)); } else { var args = tokens.Select(x => _factory.Create(x.Value)).ToList(); if (True(args[0].Eval(env).Value)) { return(args[1].Eval(env)); } } } } return(new SelfEvaluatingExpression(false).ToResult()); }
protected override EvalResult EvalImpl(ScmEnvironment env) { if (_arguments[0].Type == TokenType.Symbol) { DefineVariable(_arguments[0].Value, _factory.Create(_arguments[1].Value), env); } else if (_arguments[0].Type == TokenType.Tuple) { var pars = _tokenizer.Parse(_tokenizer.Strip(_arguments[0].Value)).ToList(); var newVariable = pars[0].Value; var lambda = new LambdaExpression(_factory.Create(_arguments[1].Value), pars.Skip(1).Select(x => x.Value).ToArray(), env); var newValue = lambda.Eval(env).Value; DefineVariable(newVariable, newValue, env); } return(new VoidExpression().ToResult()); }
public static IIntelliFlowItem Create(Domain.IntelliFlowItem item, IDataContext context) { var fac = _itemFac[(Enums.IntelliFlowItemType)item.ItemTypeId]; var newItem = fac.Create(item.ItemTypeId); IDataRepository <Domain.IntelliFlowItem> itemRepos = new EFDataRepository <Domain.IntelliFlowItem>(context); IDataRepository <Domain.Expression> exprRepos = new EFDataRepository <Domain.Expression>(context); var childItems = itemRepos.Query(x => x.ParentItemId == (long)item.Id).ToArray(); if (!childItems.IsNullOrEmpty()) { var childItemList = new List <IIntelliFlowItem>(); foreach (var child in childItems) { var newChild = _Create(child, context, true); childItemList.Add(newChild); } newItem.Children = new IntelliFlowIterator <IIntelliFlowItem>(childItemList.ToArray()); } if (item.ParentItemId.HasValue) { var parent = itemRepos.Get(item.ParentItemId.Value); var newParent = _Create(parent, context, false); newItem.Parent = newParent; } if (!item.Data.IsNullOrEmpty()) { newItem.Input.Data = BinarySerializer.Deserialize((NEMILTEC.Shared.Enums.Data.DataType)item.DataTypeId, item.Data); } var itemExp = exprRepos.Query(x => x.ParentItemId == (long)item.Id).ToArray(); if (!itemExp.IsNullOrEmpty()) { var paramList = new List <IntelliFlowItemInputParameter>(); foreach (var exp in itemExp) { var param = new IntelliFlowItemInputParameter(); var newExp = ExpressionFactory.Create(exp, context); if (newExp is ValueExpression) { var valExp = newExp as ValueExpression; param.Value = valExp.Value; } param.Expression = newExp; paramList.Add(param); } newItem.Input.Parameters = paramList; } return(newItem); }
public virtual IQueryable <T> Sort <T>(IQueryable <T> query, object request) { var configuration = GetRequestModelListConfiguration(request); var sortColumn = (string)configuration.SortColumnConfiguration?.RequestProperty?.GetValue(request); var sortDirection = (Direction?)configuration.SortDirectionConfiguration?.RequestProperty?.GetValue(request); if (string.IsNullOrWhiteSpace(sortColumn) || sortDirection == null) { return(query); } var expression = ExpressionFactory.Create <T>(sortColumn); return(sortDirection == Direction.Ascending ? query.OrderBy(expression) : query.OrderByDescending(expression)); }
private static NEMILTEC.Interfaces.Service.Reporting.ReportElementParameter _CreateElementParameter(Domain.ReportElementParameter reportElementParam, IDataContext context) { var newElementParam = new NEMILTEC.Interfaces.Service.Reporting.ReportElementParameter { Name = reportElementParam.Name, Value = BinarySerializer.Deserialize( (NEMILTEC.Shared.Enums.Data.DataType)reportElementParam.Expression.DataType.Id, reportElementParam.Expression.Value), DataType = (NEMILTEC.Shared.Enums.Data.DataType)reportElementParam.Expression.DataType.Id }; if (reportElementParam.Expression != null) { newElementParam.Expression = ExpressionFactory.Create(reportElementParam.Expression, context); } return(newElementParam); }