Exemple #1
0
        /// <summary>
        /// コンストラクタ
        /// </summary>
        /// <param name="operation">IOperationインスタンス</param>
        /// <param name="container">イベントコンテナ</param>
        public Literal(ILiteralOperation operation, EventContainer container) : base(container)
        {
            var literalValue = operation.ConstantValue.Value;

            // nullの場合はその情報を格納して終了
            if (literalValue is null)
            {
                var type = "null";
                Expressions.Add(new Expression(type, type));
                return;
            }

            // 各Typeごとの加工処理
            if (literalValue is string)
            {
                literalValue = $"\"{literalValue}\"";
            }
            if (literalValue is bool)
            {
                literalValue = $"{literalValue}".ToLower(CultureInfo.CurrentCulture);
            }

            // 情報格納
            Expressions.Add(new Expression(literalValue.ToString(), Expression.GetSymbolTypeName(operation.Type)));
        }
        private Func <T, string> BuildLambda(CompilerContext compilationContext, List <Expression> blockContext)
        {
            var @params = new List <ParameterExpression>(1 + PartialExpressionCache.Count)
            {
                Builder
            };

            foreach (var partial in PartialExpressionCache)
            {
                Expressions.Add(Expression.Assign(partial.Value.Variable, partial.Value.Partial));
                @params.Add(partial.Value.Variable);
            }

            if (blockContext.Count > 0)
            {
                Expressions.Add(Expression.Block(blockContext));
            }

            Expressions.Add(Expression.Call(Builder, MethodInfos.Instance.StringBuilderToString));

            var param = (ParameterExpression)compilationContext.SourceData;

            var lambda = Expression.Lambda <Func <T, string> >(Expression.Block(@params, Expressions), param);

            return(lambda.Compile());
        }
Exemple #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FileExpressionList"/> class.
        /// </summary>
        /// <param name="rawFileListString">The unprocessed list of file expressions.</param>
        /// <param name="project">The project where the expression list exists.</param>
        /// <param name="task">The task where the expression list exists.</param>
        public FileExpressionList(string rawFileListString, ProjectInstance project, ProjectTaskInstance task)
        {
            IList <string> expressions = rawFileListString.SplitStringList();
            var            seenFiles   = new HashSet <string>(PathComparer.Instance);

            foreach (string expression in expressions)
            {
                FileExpressionBase parsedExpression = FileExpressionFactory.ParseExpression(expression, project, task);
                Expressions.Add(parsedExpression);

                foreach (string file in parsedExpression.EvaluatedFiles)
                {
                    if (string.IsNullOrWhiteSpace(file))
                    {
                        continue;
                    }

                    if (seenFiles.Add(file))
                    {
                        DedupedFiles.Add(file);
                    }

                    AllFiles.Add(file);
                }
            }
        }
        public void RebuildList(bool refreshStatistics = false, bool resetPageIndex = false)
        {
            Log.StartTiming();

            Expressions.Clear();

            if (resetPageIndex)
            {
                PagingHelper.PageChanged -= PagingHelper_PageChanged;
                PagingHelper.FirstPage();
                PagingHelper.PageChanged += PagingHelper_PageChanged;
            }

            var srv = DataAccess;
            var res = srv.GetPage(GetPageParameters);

            foreach (var entity in res)
            {
                Expressions.Add(ServiceProvider.Inject(new ExpressionVM(this, entity)));
            }

            if (refreshStatistics)
            {
                RefreshStatistics();
            }

            Log.StopTiming();
        }
Exemple #5
0
        public void SetExpressionsFromExpressionsText()
        {
            if (ExpressionsText is null)
            {
                return;
            }

            Expressions.Clear();
            string[] lines = IPBanConfig.CleanMultilineString(ExpressionsText).Split('\n');
            string   line;
            EventViewerExpression currentExpression = null;

            for (int i = 0; i < lines.Length; i++)
            {
                line = lines[i].Trim();
                if (line.StartsWith("//") || line.StartsWith("(//"))
                {
                    if (currentExpression != null)
                    {
                        Expressions.Add(currentExpression);
                    }
                    currentExpression = new EventViewerExpression {
                        XPath = line, Regex = string.Empty
                    };
                }
                else if (line.Length != 0 && currentExpression != null)
                {
                    currentExpression.Regex += line + "\n";
                }
            }
            if (currentExpression != null)
            {
                Expressions.Add(currentExpression);
            }
        }
Exemple #6
0
 /// <summary>
 /// 終了括弧の確認と追加
 /// </summary>
 /// <param name="targetOpration">対象Oprationインスタンス</param>
 private void CloseParentheses(IOperation targetOpration)
 {
     if (targetOpration is IBinaryOperation && ExistsParentheses(targetOpration))
     {
         Expressions.Add(new Expression(")", string.Empty));
     }
 }
Exemple #7
0
        protected ExpressionBase ParseShorthandBody(PositionalTokenizer tokenizer)
        {
            ExpressionBase.SkipWhitespace(tokenizer);

            var expression = ExpressionBase.Parse(tokenizer);

            if (expression.Type == ExpressionType.ParseError)
            {
                return(expression);
            }

            switch (expression.Type)
            {
            case ExpressionType.Return:
                return(ParseError(tokenizer, "Return statement is implied by =>", ((ReturnExpression)expression).Keyword));

            case ExpressionType.For:
                return(ParseError(tokenizer, "Shorthand function definition does not support loops.", expression));

            case ExpressionType.If:
                return(ParseError(tokenizer, "Shorthand function definition does not support branches.", expression));
            }

            var returnExpression = new ReturnExpression(expression);

            Expressions.Add(returnExpression);
            Location = new TextRange(Location.Start, expression.Location.End);
            return(MakeReadOnly(this));
        }
        public void Parse()
        {
            File.Copy(TemplateFile, TempFile, true);
            Doc = DocX.Load(TempFile);
            string        re = "{{.+?}}";
            List <string> es = Doc.FindUniqueByPattern(re, regexOptions);

            Expressions = es.Select(s => Expression <SCOPE> .Factory(s, new SCOPE())).ToList();
            Regex regex = new Regex(@"{{(.+)\[i\]");

            foreach (Expression <SCOPE> e in Expressions.ToList())
            {
                Match m = regex.Match(e.Raw);
                if (m.Success)
                {
                    string code = m.Groups[1].Value;
                    code += ".Count";
                    Expressions.Add(new Expression <SCOPE>(Scope)
                    {
                        Code = code
                    });
                    for (int i = 0; i <= NbIteration - 1; i++)
                    {
                        code = e.Code.Replace("[i]", "[" + i + "]");
                        Expressions.Add(new Expression <SCOPE>(Scope)
                        {
                            Code = code
                        });
                    }
                }
            }
        }
Exemple #9
0
 public ComplexExpression(Expression[] exprs)
 {
     for (int i = 0; i < exprs.Length; i++)
     {
         Expressions.Add(exprs[i]);
     }
 }
Exemple #10
0
 public void Visit(LetExp node)
 {
     Expressions.Add(node.Variable.Value);
     Expressions.Add(node.InExpression);
     node.Variable.Value.Accept(this);
     node.InExpression.Accept(this);
 }
Exemple #11
0
            protected override Expression VisitBinary(BinaryExpression node)
            {
                var nodeType = node.NodeType;

                if (nodeType == ExpressionType.AndAlso ||
                    nodeType == ExpressionType.OrElse)
                {
                    var left       = Visit(node.Left);
                    var right      = Visit(node.Right);
                    var conversion = Visit(node.Conversion);

                    if (left != node.Left || right != node.Right || conversion != node.Conversion)
                    {
                        if (node.NodeType == ExpressionType.Coalesce && node.Conversion != null)
                        {
                            return(Expression.Coalesce(left, right, conversion as LambdaExpression));
                        }

                        return(Expression.MakeBinary(node.NodeType, left, right, node.IsLiftedToNull, node.Method));
                    }
                }
                else
                {
                    Expressions.Add(node);
                }

                return(node);
            }
 /// <summary>
 /// Recursively continues to build the document object tree.
 /// </summary>
 /// <param name="values">The child outlines to parse.</param>
 private void ParseExpressions(params string[] values)
 {
     if (values.Length > 0)
     {
         Expressions = new List <List <LatexExpression> >(values.Length);
     }
     for (int i = 0; i < values.Length; i++)
     {
         var             list      = new List <LatexExpression>();
         string          beginning = values[i];
         string          end;
         LatexExpression expr;
         int             index            = 0;
         bool            verbatimMode     = false;
         bool            mathMode         = MathMode;
         bool            whitespaceBefore = false;
         while ((expr = ReadFromTextReader(this, i, ref index, ref verbatimMode,
                                           mathMode | ExprType == ExpressionType.InlineMath | ExprType == ExpressionType.BlockMath,
                                           Customization, beginning, null, out end, ref whitespaceBefore)) != null)
         {
             CheckMathMode(expr, ref mathMode);
             beginning = end;
             list.Add(expr);
         }
         Expressions.Add(list);
     }
 }
        public MathExpressions()
        {
            var first = new Expression();

            Expressions.Add(first);
            _instance = this;
        }
Exemple #14
0
        /// <summary>
        /// 加载xml时解析表达式
        /// </summary>
        /// <param name="p_reader"></param>
        public override void ReadXml(XmlReader p_reader)
        {
            base.ReadXml(p_reader);

            string val = _data.Str("val").Trim();

            if (string.IsNullOrEmpty(val))
            {
                return;
            }

            if (!val.StartsWith(":"))
            {
                IsScriptRender = (val.ToLower() == ScriptValue);
                return;
            }

            // 解析表达式
            if (Expressions == null)
            {
                Expressions = new List <RptExpression>();
            }
            string[] subs = val.Substring(1).Split('+');
            foreach (string item in subs)
            {
                string str = item.Trim();
                if (str != "")
                {
                    Expressions.Add(ParseExpression(str));
                }
            }
        }
Exemple #15
0
 public GetterFunction(ClassMember classMember) : base(classMember.Owner, $"get{classMember.Name.ToUpperFirstCharacter()}", classMember.Type)
 {
     ClassMember = classMember;
     Expressions.Add(new ReturnExpression {
         ClassMember = classMember
     });
 }
Exemple #16
0
 public void Visit(IterateExp node)
 {
     Expressions.Add(node.Result.Value);
     Expressions.Add(node.Body);
     node.Body.Accept(this);
     node.Result.Value.Accept(this);
 }
Exemple #17
0
        /// <inheritdoc />
        public void Add(IExpression item)
        {
            Expressions.Add(item);
            NotifyCollectionChangedEventArgs e = new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, item);

            RaiseCollectionChanged(e);
        }
Exemple #18
0
 public WhereQuery(Expression <Func <T, bool> > expression)
 {
     Expressions.Add(new WhereExpression()
     {
         ExpressType = ExpressionType.AndAlso,
         Expression  = expression,
     });
 }
Exemple #19
0
 public void Visit(ClassLiteralExp node)
 {
     foreach (KeyValuePair <string, TupleLiteralPart> kvp in node.Parts)
     {
         Expressions.Add(kvp.Value.Value);
         kvp.Value.Value.Accept(this);
     }
 }
Exemple #20
0
 /// <summary>
 /// 创建动态表达式对象
 /// </summary>
 /// <param name="expression"></param>
 public Queryable(Expression <Func <T, bool> > expression)
 {
     Expressions.Add(new QueryableExpression()
     {
         ExpressType = ExpressionType.AndAlso,
         LambdaWhere = expression,
     });
 }
Exemple #21
0
        public TBuilder RawCondition(Action <RawConditionExpressionBuilder> action)
        {
            var builder = RawConditionExpressionBuilder.Create();

            Expressions.Add(builder);
            action(builder);
            return(this as TBuilder);
        }
Exemple #22
0
 /// <summary>
 /// Expressions the specified SQL expression.
 /// </summary>
 /// <param name="sqlExpression">The SQL expression.</param>
 /// <returns></returns>
 public Select Expression(string sqlExpression)
 {
     _provider        = ProviderFactory.GetProvider();
     this.sqlFragment = _provider.SqlFragment;
     SQLCommand       = this.sqlFragment.SELECT;
     Expressions.Add(sqlExpression);
     return(this);
 }
Exemple #23
0
        public Repetition(int min, int max, bool lazy)
        {
            Expressions.Add(null);

            this.min  = min;
            this.max  = max;
            this.lazy = lazy;
        }
 protected override Expression VisitSubQuery(SubQueryExpression expression)
 {
     if (expression.QueryModel.ResultOperators.Count == 0)
     {
         Expressions.Add(expression);
     }
     return(base.VisitSubQuery(expression));
 }
Exemple #25
0
        /// <summary>
        /// コンストラクタ
        /// </summary>
        /// <param name="operation">IOperationインスタンス</param>
        /// <param name="container">イベントコンテナ</param>
        public Invocation(IInvocationOperation operation, EventContainer container) : base(container)
        {
            if (operation.Instance is null)
            {
                // 組み込み・クラスメンバ
                var nameSpace = $"{operation.TargetMethod.ContainingNamespace.Name}.";
                var className = $"{operation.TargetMethod.ContainingType}".Replace(nameSpace, string.Empty, System.StringComparison.CurrentCulture);
                Expressions.Add(new Expression(className, string.Empty));
            }
            else
            {
                // インスタンス
                var isLiteralOrBinary = false;
                if (operation.Instance is ILiteralOperation || operation.Instance is IBinaryOperation)
                {
                    isLiteralOrBinary = true;
                }

                var syntax = operation.Syntax as InvocationExpressionSyntax;
                if (isLiteralOrBinary && syntax.ArgumentList != null)
                {
                    Expressions.Add(new Expression(syntax.ArgumentList.OpenParenToken.Text, string.Empty));
                }

                Expressions.AddRange(OperationFactory.GetExpressionList(operation.Instance, container));

                if (isLiteralOrBinary && syntax.ArgumentList != null)
                {
                    Expressions.Add(new Expression(syntax.ArgumentList.CloseParenToken.Text, string.Empty));
                }
            }
            Expressions.Add(new Expression(".", string.Empty));

            // メソッドがローカルメソッドの場合はクリアする
            if (operation.TargetMethod.MethodKind == MethodKind.LocalFunction)
            {
                Expressions.Clear();
            }

            // メソッド名
            Expressions.Add(new Expression(operation.TargetMethod.Name, operation.TargetMethod.MethodKind.ToString()));

            // メソッドパラメータ
            Expressions.Add(new Expression("(", string.Empty));
            var isFirst = true;

            foreach (var arg in operation.Arguments)
            {
                if (!isFirst)
                {
                    Expressions.Add(new Expression(",", string.Empty));
                }
                Expressions.AddRange(OperationFactory.GetExpressionList(arg.Value, container));

                isFirst = false;
            }
            Expressions.Add(new Expression(")", string.Empty));
        }
            internal SolverContext Expression <T>(Func <Solver, T> expr)
                where T : IntExpr
            {
                var x = expr(Solver);

                Expressions.Add(x);
                Clr.Add(x);
                return(this);
            }
 public ExpressionBuilder AddEqualsTo(EntityFieldMetaData field)
 {
     Expressions.Add(new EqualToOperatorExpression
     {
         Left  = new EntityFieldMetaDataExpression(field),
         Right = new ParameterExpression("@" + field.Name)
     });
     return(this);
 }
        private void AddExpression(object result)
        {
            if (result != null)
            {
                var res = result.ToString();

                Expressions.Add(new Equation(_expression, res));
            }
        }
Exemple #29
0
        public override void PopExpressionInStarck(string element, Stack <IExpression> stack)
        {
            var stackCount = stack.Count;

            for (int i = 0; i < stackCount; i++)
            {
                Expressions.Add(stack.Pop());
            }
        }
Exemple #30
0
 public void Visit(IfExp node)
 {
     Expressions.Add(node.Condition);
     Expressions.Add(node.ThenExpression);
     Expressions.Add(node.ElseExpression);
     node.Condition.Accept(this);
     node.ThenExpression.Accept(this);
     node.ElseExpression.Accept(this);
 }