コード例 #1
0
        protected override void VisitElementFragment(HxlElement fragment)
        {
            var hxlRenderElement = fragment as HxlRenderWorkElement;

            if (hxlRenderElement != null)
            {
                VisitRender(hxlRenderElement);
                return;
            }

            string varName = CodeUtility.EmitInstantiation(this.manager, this.output, fragment);

            EmitRenderingThunk(this.output, varName, fragment);

            DoAppend(varName); // Must occur first for factory methods such as AppendText to work
            DoChildVisit(fragment, varName, true);
        }
コード例 #2
0
        protected override void VisitAttributeFragment(HxlAttribute fragment)
        {
            HxlExpressionAttribute werk = fragment as HxlExpressionAttribute;

            if (werk == null)
            {
                string variable = CodeUtility.EmitInstantiation(this.manager, this.output, fragment);
                EmitRenderingThunk(this.output, variable, fragment);
                DoAppend(variable);
            }
            else
            {
                string varName = SafeNewVariable(werk.GetType().Name, true);
                // TODO Possibly better to use other name in this attribute render closure

                werk.GetInitCode(varName, this, output);
                DoAppend(varName);
            }
        }
コード例 #3
0
        public void EmitInstantiation_should_generate()
        {
            var    manager = new ExpressionSerializationManager();
            var    output  = new StringWriter();
            string name;

            using (manager.CreateSession()) {
                name = CodeUtility.EmitInstantiation(manager, output, new A());
            }

            // TODO Empty statement and extra ws are generated
            Assert.Equal("a1", name);
            Assert.Equal(
                @"Carbonfrost.UnitTests.Hxl.A a1;
Carbonfrost.UnitTests.Hxl.B b1;
a1 = new Carbonfrost.UnitTests.Hxl.A();
a1.B = b1 = new Carbonfrost.UnitTests.Hxl.B();
b1.C = 420;
b1.D = true;
;

", output.ToString());
        }