コード例 #1
0
        public void TestLambdaExpression()
        {
            var cdv = new MustacheConfig();
            var dv  = new Dictionary <string, object>
            {
                { "TargetFrameworkVersion", "netcoreapp2.2" },
            };
            var calcExp = new CalculatedParam
            {
                Name           = "AspNetCoreVersion",
                Expression     = "dataView => dataView[\"TargetFrameworkVersion\"]==\"netcoreapp2.2\"? \"2.2.0\": null",
                ExpressionType = ExpressionTypeEnum.Lambda,
            };

            cdv.EvaluateLambdaExpression <string>(calcExp.Name, calcExp.Expression, dv);
            Assert.Contains(dv, (item) => item.Key == calcExp.Name && (string)item.Value == "2.2.0");
        }
コード例 #2
0
        public void TestExpressionsActuators()
        {
            var cdv = new MustacheConfig();
            var dv  = new Dictionary <string, object>
            {
                { "MySql", true },
                { "MySqlEFCore", false },
            };
            var calcExp = new CalculatedParam
            {
                Name           = "MySqlOrMySqlEFCore",
                Expression     = "MySql || MySqlEFCore",
                ExpressionType = ExpressionTypeEnum.Lookup,
            };

            var lambda = cdv.BuildLookupLambda(calcExp, dv);

            cdv.EvaluateLambdaExpression <bool>(calcExp.Name, lambda, dv);
            Assert.Contains(dv, (item) => item.Key == calcExp.Name && item.Value is bool itemValue && itemValue);
        }