using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using ComponentPro;

namespace DynamicEmailContent
{
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class Window1 : Window
    {
        public Window1()
        {
            InitializeComponent();

            using (StreamReader sr = new StreamReader(AppDomain.CurrentDomain.BaseDirectory + "EmailTemplate.htm"))
            {
                txtTemplate.Text = sr.ReadToEnd();
            }
        }

        private void btnGenerate_Click(object sender, RoutedEventArgs e)
        {
            TemplateEngine dt = new TemplateEngine();

            dt.LoadFromString(txtTemplate.Text);
            // Create an user defined object.
            User u = 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();
        }
    }
}
