public Add ( |
||
serviceType | Service type to register. It must not already exist in this container otherwise an exception is thrown. | |
serviceInstance | Func |
Delegate to call when needed. Can not be null. |
onRemove | Action |
Optional action that will be called whenever |
return | ISimpleServiceContainer |
public ISimpleServiceContainer Add( Type serviceType, Func<Object> serviceInstance, Action<Object> onRemove )
{
if( ReferenceEquals( serviceType, null ) ) throw new ArgumentNullException( "serviceType" );
if( serviceInstance == null ) throw new ArgumentNullException( "serviceInstance" );
if( GetDirectService( serviceType ) != null ) throw new CKException( CoreResources.ServiceAlreadyDirectlySupported, serviceType.FullName );
DoAdd( serviceType, new ServiceEntry() { Instance = null, Creator = serviceInstance, OnRemove = onRemove } );
return this;
}
SimpleServiceContainer::Add ( |
MiniContext( string name ) { ServiceContainer = new SimpleServiceContainer(); ServiceContainer.Add( RequirementLayerSerializer.Instance ); ServiceContainer.Add( SimpleTypeFinder.Default ); ConfigContainer = SharedDictionary.Create( ServiceContainer ); ConfigManager = ConfigurationManager.Create( ConfigContainer ).ConfigManager; }