private void btnGo_Click(object sender, EventArgs e) { var container = AmDemoModule.RegisterDependencies(); using (var scope = container.BeginLifetimeScope()) { var _formHelper = scope.Resolve <IFormHelper>(); var customer = _formHelper.GetCustomer(); if (customer != null && !string.IsNullOrEmpty(customer.Firstname)) { tbFirstname.Text = customer.Firstname; tbLastname.Text = customer.Lastname; tbAge.Text = customer.Age.ToString(); tbGender.Text = customer.Gender.ToString(); } } }
static void Main(string[] args) { Console.WriteLine("Welcome to the AutoMapper Console App Demo"); Console.WriteLine("------------------------------------------"); Console.WriteLine("\n\n"); var container = AmDemoModule.RegisterDependencies(); using (var scope = container.BeginLifetimeScope()) { var _consoleHelper = scope.Resolve <IConsoleHelper>(); var customer = _consoleHelper.GetCustomer(); if (customer != null && !string.IsNullOrEmpty(customer.Firstname)) { Console.WriteLine($"First name: {customer.Firstname}"); Console.WriteLine($"Lastname: {customer.Lastname}"); Console.WriteLine($"Age: {customer.Age}"); Console.WriteLine($"Gender: {customer.Gender}"); } } Console.Read(); }