コード例 #1
0
        public void MapReduceTest()
        {
            string xml1 = @"<MapReduce>
                            <Map>
                                <MapRule Type = 'MapRuleOnT2' />
                            </Map>
                            <Reduce>
                                <ReduceRule Type = 'ReduceRuleOnT2' />
                                <ReduceRule Type = 'AssignRuleOnT2' />
                            </Reduce>
                        </MapReduce>";
            Parser parser = xml1.CreateParser("MapReduce");
            parser.AddContext("MapRuleOnT2", "ClassLibrary1.MapRuleOnT2, ClassLibrary1");
            parser.AddContext("ReduceRuleOnT2", "ClassLibrary1.ReduceRuleOnT2, ClassLibrary1");
            parser.AddContext("AssignRuleOnT2", "ClassLibrary1.AssignRuleOnT2, ClassLibrary1");
            Assert.IsTrue(parser.Build());
            ParserResult t2result = parser.Result;
            var parserResult = t2result.Expression;
            var resultFunc = (Expression<Func<Test2, Test2>>)parserResult;

            Func<Test2, Test2> func = resultFunc.Compile();

            var t1 = new Test2() { B = 10 };
            Test2 result = func(t1);
        }
コード例 #2
0
        public void ForEachOnlyRule()
        {
            string xml = @"
                <Map>
                    <MapRule Type = 'MapRuleOnT2' />
                    <ForEach>
                      <Rule Type = 'IninValueOnT3'/>
                    </ForEach>
                </Map>";
            Parser parser = xml.CreateParser("Map");
            parser.AddContext("MapRuleOnT2", "ClassLibrary1.MapRuleOnT2, ClassLibrary1");
            parser.AddContext("IninValueOnT3", "ClassLibrary1.IninValueOnT3, ClassLibrary1");
            Assert.IsTrue(parser.MapBlock());
            var parserResult = parser.Result.Expression;
            var resultFunc = (Expression<Func<Test2, IEnumerable<Test3>>>)parserResult;

            Func<Test2, IEnumerable<Test3>> func = resultFunc.Compile();

            var t2 = new Test2() { B = 2 };
            IEnumerable<Test3> result = func(t2);
            Assert.AreEqual(2, result.Count());
        }