The porpuse

I was looking for a very light weight IoC contanier for SharePoint Development that does not required a full framework to deploy in production enviroment and because I don´t like the service locator P&P solution recomended, so I build my own Solution and will enjoy to share with some to have the same concern or just 4Fun and educational purpose.

 

The code example included in the download use the Passive view Pattern resolving everything in the presenter and configure in the code behind of the page the view the results are a clean code about the logic of the view in the presenter like has to be.

   1:  public partial class _Default : System.Web.UI.Page, IDefaultVista
   2:      {
   3:          private IDefaultPresentador _presentador;
   4:          private readonly Container4Fun _myIoC = new Container4Fun();
   5:          protected override void OnInit(EventArgs e)
   6:          {
   7:              base.OnInit(e);
   8:              _myIoC.Register<IDefaultVista, _Default>(null,this,PropertiesTypeCondition.DisposeAll);
   9:              _myIoC.Register<IDefaultPresentador, DefaultPresentador>();
  10:              _myIoC.Register<IClienteRepositorio, ClienteRepositorio>();
  11:              _myIoC.Register<ILogger, AnotherLoggerServicio>(null, null,PropertiesTypeCondition.DisposeAll, InstanceTypeCondition.Share);
  12:              _myIoC.Register<ILogger, LoggerWebServicio>("TestLogger");
  13:              _myIoC.Register<ILogger, LoggerServicio>("PLogger");
  14:              _myIoC.Register<IConfiguracionRepositorio, ConfiguracionRepositorio>();
  15:              _presentador = _myIoC.Resolve<IDefaultPresentador>();
  16:          }
  17:          public event EventHandler VistaCargandose;
  18:   
  19:          protected void Page_Load(object sender, EventArgs e)
  20:          {
  21:              if (VistaCargandose != null)
  22:                  VistaCargandose(sender, e);
  23:          }
  24:   
  25:          public IEnumerable Clientes
  26:          {
  27:              set
  28:              {
  29:                  CapturaClientes.DataSource = value;
  30:                  CapturaClientes.DataBind();
  31:              }
  32:          }
  33:      } 

Last edited Jan 4, 2011 at 4:52 AM by jmho, version 1

Comments

No comments yet.