private void DisplayTemplate(string html) { List <TemplateObject> templateList = TemplateAnalyser.AnalyseTemplateList(html); DisplayTemplate(templateList, -1); ScriptManager.RegisterStartupScript(this, this.GetType(), "FinishInitTemplateContainer", "FinishInit();", true); }
public void TestAnalyseTemplateList_一般情况() { string html = string.Empty; using (StreamReader reader = new StreamReader(TestContext.TestDeploymentDir + "\\TemplateFiles\\10.综合测试.一般情况.htm")) { html = reader.ReadToEnd(); reader.Close(); } List <TemplateObject> infoList = TemplateAnalyser.AnalyseTemplateList(html); Assert.IsNotNull(infoList); Assert.AreEqual(2, infoList.Count); TemplateObject info1 = infoList[0]; Assert.AreEqual("list", info1.Category); Assert.AreEqual("TestDisp1", info1.DisplayName); Assert.AreEqual("Image", info1.DataType); Assert.AreEqual(1, info1.Children.Count); Assert.AreEqual("Sub1", info1.Children[0].DisplayName); TemplateObject info2 = infoList[1]; Assert.AreEqual("item", info2.Category); Assert.AreEqual("TestDisp2", info2.DisplayName); Assert.AreEqual("String", info2.DataType); Assert.AreEqual(0, info2.Children.Count); }
public void TestAnalyseTemplate_一般情况() { string html = string.Empty; using (StreamReader reader = new StreamReader(TestContext.TestDeploymentDir + "\\TemplateFiles\\01.单个模板项.一般情况.htm")) { html = reader.ReadToEnd(); reader.Close(); } TemplateObject info = TemplateAnalyser.AnalyseTemplate(html); Assert.IsNotNull(info); Assert.AreEqual("list", info.Category); Assert.AreEqual("TestDisp", info.DisplayName); Assert.AreEqual("Image", info.DataType); Assert.AreEqual(html.ToString(), info.OuterHTML); Assert.AreEqual("\r\n<div>\r\n <span style=\"font-family: 幼圆; font-size: 1.5em;\"></span>\r\n</div>\r\n", info.InnerHTML); }
public string GetHtml() { string html = TemplateHtml; List <TemplateObject> templateList = TemplateAnalyser.AnalyseTemplateList(html); if (CurrentTemplateSetFlow != null) { foreach (TemplateObject obj in templateList) { string oldText = obj.OuterHTML; string newText = string.Empty; foreach (TemplateSetItem flow in CurrentTemplateSetFlow.CurrentFlowList) { if (obj.Id == flow.ContainerId) { newText += GetItemHtmlByFlow(flow, obj); } } html = html.Replace(oldText, newText); } } return(html); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack && !string.IsNullOrEmpty(TemplateHtml)) { List <TemplateObject> templateList = TemplateAnalyser.AnalyseTemplateList(TemplateHtml); rptBlocks.DataSource = templateList; rptBlocks.DataBind(); if (CurrentTemplateSetFlow != null) { foreach (TemplateSetItem flow in CurrentTemplateSetFlow.CurrentFlowList) { foreach (RepeaterItem row in rptBlocks.Items) { CtrlBlock_Container container = (CtrlBlock_Container)row.FindControl("ucCtrlBlockContainer"); if (container.TemplateId == flow.ContainerId) { container.CreateChild(flow); } } } } } }
public void TestAnalyseTemplate_空字符串情况() { TemplateAnalyser.AnalyseTemplate(string.Empty); }