示例#1
0
        public string Parse(string template)
        {
            string ret;
            IRuntimeAssembly t;

            if (!IsCached(template, out t))
            {
                string code = new Parser().Parse(template);
                StringBuilder sb = new StringBuilder(String.Join("\r\n", Usings));
                sb.Append(GetClassBoilerplate());
                sb.Append(code);
                sb.Append(GetFinisherBoilerplate());
                t = GetAssembly(sb.ToString());
                cachedAssemblies[GetHash(template)] = t;
            }

            ret = t.GetTemplate();

            return ret;
        }
示例#2
0
        public string Parse(string template, List<ParamTypeInfo> parms)
        {
            string ret;
            IRuntimeAssembly t;

            if (!IsCached(template, out t))
            {
                string code = new Parser().Parse(template);
                StringBuilder sb = new StringBuilder(String.Join("\r\n", Usings));
                sb.Append(GetClassBoilerplate());
                InitializeParameters(sb, parms);
                sb.Append(code);
                sb.Append(GetFinisherBoilerplate());
                t = GetAssembly(sb.ToString());
                cachedAssemblies[GetHash(template)] = t;
            }

            object[] objParms = parms.Select(p => p.ParamValue).ToArray();
            ret = t.GetTemplate(objParms);

            return ret;
        }