Esempio n. 1
0
        public virtual void Write(ICodeFragment fragment, IOutputCache output)
        {
            TypeScriptTemplate template = (TypeScriptTemplate)fragment;

            output.Add(template.Code);
            if (template.CloseAfter)
            {
                output.CloseLine();
            }
            if (template.BreakAfter)
            {
                output.BreakLine();
            }
            if (template.StartBlockAfter)
            {
                output.StartBlock();
            }
            if (template.EndBlockAfter)
            {
                output.EndBlock();
            }
            if (template.IndentAfter)
            {
                output.Indent();
            }
            if (template.UnindentAfter)
            {
                output.UnIndent();
            }
        }
        public virtual void Write(ICodeFragment fragment, IOutputCache output)
        {
            AnonymousObjectTemplate template = (AnonymousObjectTemplate)fragment;

            output.Add("{")
            .Indent();
            PropertyValueTemplate last = template.Properties.LastOrDefault();

            foreach (PropertyValueTemplate property in template.Properties)
            {
                output.Add($"{property.Name}: ")
                .Add(property.Value)
                .If(property != last).Add(",").EndIf()
                .BreakLine();
            }
            output.UnIndent().Add("}");
        }