/// <summary>
        /// Add an extension to the container.
        /// </summary>
        /// <param name="extension"><see cref="UnityContainerExtension"/> to add.</param>
        /// <returns>The <see cref="IUnityContainer"/> object that this method was called on (this in C#, Me in Visual Basic).</returns>
        public IUnityContainer AddExtension(IUnityContainerExtensionConfigurator extension)
        {
            lock (LifetimeContainer)
            {
                if (null == _extensions)
                {
                    _extensions = new List <IUnityContainerExtensionConfigurator>();
                }

                _extensions.Add(extension ?? throw new ArgumentNullException(nameof(extension)));
            }
            (extension as UnityContainerExtension)?.InitializeExtension(_context);

            return(this);
        }
예제 #2
0
 /// <summary>
 /// Add an extension to the container.
 /// </summary>
 /// <param name="extension"><see cref="UnityContainerExtension"/> to add.</param>
 /// <returns>The <see cref="IUnityContainer"/> object that this method was called on (this in C#, Me in Visual Basic).</returns>
 public static IUnityContainer AddExtension(this IUnityContainer container, IUnityContainerExtensionConfigurator extension)
 {
     return(((UnityContainer)container ?? throw new ArgumentNullException(nameof(container))).AddExtension(extension));
 }