Imports System.IO
Imports System.Text
Imports ComponentPro

Namespace DynamicEmailContent
	''' <summary>
	''' Interaction logic for Window1.xaml
	''' </summary>
	Partial Public Class Window1
		Inherits Window
		Public Sub New()
			InitializeComponent()

			Using sr As New StreamReader(AppDomain.CurrentDomain.BaseDirectory & "EmailTemplate.htm")
				txtTemplate.Text = sr.ReadToEnd()
			End Using
		End Sub

		Private Sub btnGenerate_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
			Dim dt As New TemplateEngine()

			dt.LoadFromString(txtTemplate.Text)
			' Create an user defined object.
			Dim u As New User()
			u.EmailAddress = "myemail@somedomain.com"
			u.FullName = "John Borders"
			u.Password = "123abc"

			' Assign variables.
			dt.SetValue("CompanyName", "My Company Name")
			dt.SetValue("User", u)
			dt.SetValue("OrderId", "1625DGHJ")

			txtOutput.Text = dt.Run()
		End Sub
	End Class
End Namespace
