コード例 #1
0
        public static List<MappingBuilderNode> BuildExpressionTree(ExpressionPair[] mappings)
        {
            var expressionParts = mappings.Select(m => new ExpressionPart
            {
                Source = m.Source,
                SourcePath = m.Source.ToPathWithEmptyIndexer(),
                Parts = ExpressionParser.SplitExpression(m.Dest).ToArray(),
                Converter = m.Converter
            })
            .ToArray();

            var nodeMap = new Dictionary<string, MappingBuilderNode>();

            foreach (var part in expressionParts)
                CreateNodes(part.Parts, part.Source, part.Converter, 0, nodeMap);

            var result = nodeMap.Values.OfType<RootNode>()
                                       .Cast<MappingBuilderNode>()
                                       .ToList();

            return result;
        }