Tuesday

template engine .net

 
using System.Collections;

namespace Business.CustomerServices
{
public class SimpleTemplateEngine
{

public string ReadFile(string f)
{
System.IO.StreamReader file = new System.IO.StreamReader(f);
string testxmldata = file.ReadToEnd(); file.Close();
return testxmldata;
}


public string RenderFile(Hashtable values, string fileName)
{
return Render(values, ReadFile(fileName));
}


public string Render(Hashtable values, string template)
{
foreach (DictionaryEntry entry in values)
{
template = template.Replace("{$" + entry.Key + "}",""+ entry.Value);
}
return template;
}

}

}

No comments:

test smtp server with powershell

Send-MailMessage -SMTPServer smtp.domain.com -To [email protected] -From [email protected] -Subject "This is a test email" -Body ...