How do I call the constructor of an attribute before the constructor of the decorated class?
For example, I have my attribute:
using System;
namespace T.WinForm
{
public class TesteAttribute : Attribute
{
public TesteAttribute()
{
Console.WriteLine("Executei o construtor do atributo...");
}
}
}
And I have the class decorated by the previous attribute:
using System;
namespace SimT.WinForm
{
public partial class FrmMenuPrincipal : SimTForm
{
[TesteAttribute]
public FrmMenuPrincipal()
{
InitializeComponent();
Console.WriteLine("Executei o construtor da classe...");
}
}
}
I would like that when executing this code, the writing sequence of the console would look like this:
The intent is to do something like% co.de% of ASP.Net MVC.
I'm trying to do this using a WinForms application with .Net 4.5