internal static DomObject ConvertNode(DomObject attr)
        {
            var        __document   = new HxlDocument();
            DomElement root_article = __document.CreateElement("article");
            DomObject  root_article_hxlexpressionattribute = global::Carbonfrost.Commons.Hxl.HxlAttribute.Create("id", (__closure, __self__) => string.Concat((object)(__closure.Inside)));

            root_article.Append(root_article_hxlexpressionattribute);

            var conv = HxlCompilerConverter.ChooseConverter(attr);

            return(conv.Convert(attr, CSharpScriptGenerator.Instance));
        }
示例#2
0
        private HxlDocumentFragment PrepareDocument()
        {
            _metrics.StartPreprocessor();
            ParsedTemplate parsed = this;

            // TODO Consider which services belong here
            var sp = new ServiceContainer(ServiceProvider.Current);

            var all       = CreateCompilerProcessors();
            var converter = new DomConverter();
            var myDoc     = converter.Convert(parsed.SourceDocument,
                                              NewDocument(),
                                              t => _implicitAssemblyReferences.Add(t.GetTypeInfo().Assembly));

            foreach (var c in all)
            {
                c.Preprocess(myDoc, sp);
            }

            // TODO Combine adjacent text uses (performance)
            // TODO ToArray() is wasteful (performance)

            // Convert document
            HxlDocumentFragment result = NewDocument();

            foreach (var m in myDoc.ChildNodes.ToArray())
            {
                var conv = HxlCompilerConverter.ChooseConverter(m);
                conv.ConvertAndAppend(result, m, CSharpScriptGenerator.Instance);
            }

            _metrics.EndPreprocessor();

            // TODO This is a compiler settings property
            bool skipOptimizations = false;

            _metrics.TemplateOptimizerStarting("cs", !skipOptimizations);

            if (!skipOptimizations)
            {
                _metrics.StartOptimizer();
                OptimizeRenderIslands.Rewrite(result);
                _metrics.EndOptimizer();
            }

            return(result);
        }