예제 #1
0
        internal static void MatchVariablesAndEmit(IHxlTemplateEmitter builder,
                                                   string text)
        {
            var c = MatchVariables(text);

            ProcessVariablesAndEmit(c, builder, text);
        }
예제 #2
0
        private static void ProcessVariablesAndEmit(MatchCollection matches,
                                                    IHxlTemplateEmitter builder,
                                                    string text)
        {
            int previousIndex = 0;

            foreach (Match match in matches)
            {
                builder.EmitLiteral(text.Substring(previousIndex, match.Index - previousIndex));

                string expText = match.Groups["Expression"].Value;
                var    e       = ParseAndBindExpr(expText);
                builder.EmitValue(e);
                previousIndex = match.Index + match.Length;
            }
            builder.EmitLiteral(text.Substring(previousIndex, text.Length - previousIndex));
        }
예제 #3
0
        protected override void EmitCode(IHxlTemplateEmitter emitter)
        {
            string text = string.Format("{0} __model = ({0}) this.Data.Model;", Type);

            emitter.EmitCode(text);
        }
예제 #4
0
 internal void GetInitCode(string variable, IHxlTemplateEmitter context, TextWriter tw)
 {
     // TODO Possibly better to use other name in this attribute render closure
     // HACK __self__ is a hack
     tw.Write("{3} = global::{0}.Create(\"{2}\", (__closure, __self__) => {1});" + Environment.NewLine, typeof(HxlAttribute).FullName, code, attrName, variable);
 }
예제 #5
0
 internal void GetInitCode(string variable, IHxlTemplateEmitter context, TextWriter tw)
 {
     EmitCode(context);
 }
예제 #6
0
 protected virtual void EmitCode(IHxlTemplateEmitter emitter)
 {
 }