public void SimpleFormatTest() { string htmlContent = new MailTemplet(@"Hello,{userName}!").SetVariable("username", "wangqj") .ToHtmlContent(); //Console.Write(htmlContent); Debug.Assert(htmlContent.Equals("Hello,wangqj!")); }
public void SubPropertyFormat() { TempletObject obj = new TempletObject { IpAddress = "192.168.8.91", UserName = "******" }; string htmlContent = new MailTemplet(@"Hello,{user.IpAddress.Length}!").SetVariable("user", obj) .ToHtmlContent(); //Console.Write(htmlContent); Debug.Assert(htmlContent.Equals("Hello,12!")); }
public void SubComplexPropertyIndexFormat() { NameValueCollection nv = new NameValueCollection(); nv.Set("IP", "192.168.8.91"); nv.Set("UserName", "wangqj"); ComplexObject obj = new ComplexObject { Headers = nv }; string htmlContent = new MailTemplet(@"Hello,{Request.Headers[""IP""].Length}, TotalCount:{Request.Headers.Count}!").SetVariable("Request", obj) .ToHtmlContent(); //Console.Write(htmlContent); Debug.Assert(htmlContent.Equals("Hello,12, TotalCount:2!")); }
public void SubPropertyIndexFormat() { NameValueCollection nv = new NameValueCollection(); nv.Set("IP", "192.168.8.91"); nv.Set("UserName", "wangqj"); string htmlContent = new MailTemplet(@"Hello,{Request[""IP""]}!").SetVariable("Request", nv) .ToHtmlContent(); //Console.Write(htmlContent); Debug.Assert(htmlContent.Equals("Hello,192.168.8.91!")); }