You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Unity is a very flexible system. It allows customization of all of its aspects. This is some of the things Unity allows to customize:
Strategies used to build types
Custom resolvers for specific types (IEnumerable, Array, etc. )
Default lifetimes for resolved instances
Different pipelines for type, instance, and factory based resolutions
The list is not exhaustive, there are other things developers could do to adjust behavior of the container.
Configuration through extensions
Although system is highly flexible, adjusting configuration is rather awkward. To change anything, a developer required to create Unity Extension to gain access to internal settings and change defaults.
Configuration the easy way
Unity has built-in extension management mechanism, which among other things has method Configure. By default it allows access to installed extensions and provides a way to configure these as designer intended.
This mechanism could be used to configure Unity as well. There is no reason why it should not be possible to call this method like this:
and get access to the same information as custom extension.
Implementation
To implement this feature Unity will introduce new interface:
publicinterfaceIExtensionContext{/// <summary>/// Pipeline containing processors required to execute registered factories/// </summary>IStagedStrategyChain<PipelineProcessor,PipelineStage> FactoryPipeline {get;}/// <summary>/// Pipeline containing processors required to manipulate registered instances/// </summary>IStagedStrategyChain<PipelineProcessor,PipelineStage> InstancePipeline {get;}/// <summary>/// Pipeline containing processors required to create registered types/// </summary>IStagedStrategyChain<PipelineProcessor,PipelineStage> TypePipeline {get;}/// <summary>/// The policies this container uses./// </summary>/// <remarks>The <see cref="IPolicyList"/> the that container uses to build objects.</remarks>IPolicyListPolicies{get;}/// <summary>/// This event is raised when new <see cref="Type"/> is registered./// </summary>eventRegistrationEventTypeRegistered;/// <summary>/// This event is raised when new instance is registered./// </summary>eventRegistrationEventInstanceRegistered;/// <summary>/// This event is raised when new instance is registered./// </summary>eventRegistrationEventFactoryRegistered;/// <summary>/// This event is raised when the <see cref="IUnityContainer.CreateChildContainer"/> /// method is called and new child container is created. It allow extensions to /// perform any additional initialization they may require./// </summary>eventChildCreatedEventChildContainerCreated;}
The text was updated successfully, but these errors were encountered:
Configuring Unity Container
Unity is a very flexible system. It allows customization of all of its aspects. This is some of the things Unity allows to customize:
The list is not exhaustive, there are other things developers could do to adjust behavior of the container.
Configuration through extensions
Although system is highly flexible, adjusting configuration is rather awkward. To change anything, a developer required to create Unity Extension to gain access to internal settings and change defaults.
Configuration the easy way
Unity has built-in extension management mechanism, which among other things has method
Configure
. By default it allows access to installed extensions and provides a way to configure these as designer intended.This mechanism could be used to configure Unity as well. There is no reason why it should not be possible to call this method like this:
and get access to the same information as custom extension.
Implementation
To implement this feature Unity will introduce new interface:
The text was updated successfully, but these errors were encountered: