Пример #1
0
        static XDocument CreateSymbolTree(string nsUrlName, string urlName, SymbolDecl[] decls, Dictionary <string, string> symbolFileMapping)
        {
            var symbolParentMapping = new Dictionary <string, string>();
            var forest = decls
                         .Select(decl => GenerateSymbolTreeVisitor.Execute(decl, symbolParentMapping))
                         .ToArray();
            var root = SymbolTree.Merge(forest);

            foreach (var key in symbolParentMapping.Keys)
            {
                symbolFileMapping.Add(key, "s:" + urlName);
            }

            return(new XDocument(
                       new XElement("SymbolTree",
                                    new XAttribute("NamespaceUrlName", nsUrlName),
                                    new XElement("SymbolParentMapping",
                                                 symbolParentMapping
                                                 .Where(p => p.Key != p.Value)
                                                 .Select(p =>
                                                         new XElement("Map",
                                                                      new XAttribute("From", p.Key),
                                                                      new XAttribute("To", p.Value)
                                                                      )
                                                         )
                                                 ),
                                    root.Serialize()
                                    )
                       ));
        }
Пример #2
0
            private static SymbolTree ExecuteInternal(SymbolDecl decl, SymbolTree parent, Dictionary <string, string> symbolParentMapping)
            {
                var visitor = new GenerateSymbolTreeVisitor
                {
                    Parent = parent,
                    SymbolParentMapping = symbolParentMapping,
                };

                decl.Accept(visitor);
                return(visitor.Result);
            }