Пример #1
0
        private void RenderTemplate()
        {
            //Template.Debug = true;
            //var data = new Dictionary<string, object>();
            //data.Add("ProgramName", "TestAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
            //Template.Debug = true;
            //OutputText = Template.ProcessTemplate(TemplateText, data);

            Template tt = new Template();

            tt.AddTemplateItem("testTemplate", string.Format(@"<# var P=Data[""P""] as Dictionary<string, object>; #>{0}", TemplateText));
            tt.Process();
            tt.AssemblyName = "Test";

            tt.Compile();
            TemplateBase temp = tt.CreateInstance("testTemplate");
            var          P    = new Dictionary <string, object>();

            foreach (var item in ParameterList.Where(x => !x.IsTemplate).ToList())
            {
                if (item.DataType == "Array")
                {
                    List <string> values = item.ValueList.Where(x => !x.IsTemplate).Select(x => x.PropertyValue).ToList();
                    P.Add(item.PropertyName, values);
                }
                else
                {
                    P.Add(item.PropertyName, item.PropertyValue);
                }
            }

            temp.Data["P"] = P;

            OutputText = temp.Render();
        }
        public void Run()
        {
            TemplateBase template = TemplateEngine.Instance.FindTemplate(this);

            template.Render(DataContext);
        }