Is to plan the register part.  The register method of the container are overloaded and let you to play with different options

//1. The base option is Register only the contract and the implementation:
 
    _myIoC.Register<IDefaultPresentador, DefaultPresentador>();
 
//2. If you need to add different implementation of the same contract you can pass an string that represent
// the name of the property that you want to use the specific implementation. 
 
_myIoC.Register<ILogger, AnotherLoggerServicio>(); // Default implementation for ILogger contract_myIoC.Register<ILogger, LoggerWebServicio>("TestLogger"); // Specific implementarion for TestLogger Property
_myIoC.Register<ILogger, LoggerServicio>("PLogger"); // Specific Implementatio for PLogger property            
//3. If you need to add an instance already created
_myIoC.Register<IDefaultVista, _Default>(null,this); 
// Remember the first parameter is the name of the property that is not required in this example.
//4. The next option is about properties dependencies if you don´t need to Search for.  
//The options availables are (Search:Look for them
//, AllowNull: will not throw an error if them are not register
//, DisposeAll: Don’t search any property) 
 
 _myIoC.Register<IDefaultVista, _Default>(null,this,PropertiesTypeCondition.DisposeAll);      
//5. The final option is about instance of the implementation if you want to share or create one every time
// you required (The options available are: Share and NonShare)
 
_myIoC.Register<ILogger, AnotherLoggerServicio>(null, null,PropertiesTypeCondition.DisposeAll, InstanceTypeCondition.Share);

So enjoy to play with these options and see how you can free resources with planning your register dependencies.

Last edited Jan 4, 2011 at 5:15 AM by jmho, version 2

Comments

No comments yet.