I'm developing a descktop application in C # The 4.5 framework
I did not think the application could grow and have many fields, so there was a need to do automatic (from / to) mapping of controls to entities ...
Example.
public Pessoa GetPessoaForm()
{
//Obtém todos os controles de um formulário
IEnumerable<Control> controles = frm.GetAll();
Pessoa pessoa = new Pessoa();
var prop = typeof(pessoa).GetProperties();
foreach ( Controle control in controles)
{
foreach (var p in prop)
{
If(!p.Name.ToLower().Equals(control.Tag.ToString().ToLower())
continue;
If (typeof(control).Equals(typeof(TextBox))
Control.Text = p.GetValue(prop, null); //erro também
}
}
}
In this way I would like to map to the form and vice versa. From the form for entities.