Пример #1
0
        public static IUnityContainer Register(
            this IUnityContainer container,
            ContainerRegistrar registrar,
            bool isTest = false)
        {
            if (registrar == null)
            {
                throw new ArgumentNullException(nameof(registrar));
            }

            return(registrar.Register(container, isTest));
        }
Пример #2
0
        /// <summary>
        /// Registers the types and instances of the <see cref="ContainerRegistrar"/> in the specified container.
        /// The method is <b>not</b> thread safe and should be called from a synchronized context.
        /// </summary>
        /// <param name="container">The container.</param>
        /// <param name="registrar">The registrar.</param>
        /// <param name="registrations">The registrations.</param>
        /// <param name="isTest">if set to <see langword="true" /> [is test].</param>
        /// <returns>IUnityContainer.</returns>
        /// <remarks>
        /// This method allows for chained registrations like this:
        /// <code>
        /// <![CDATA[
        ///     lock (DIContainer.Initialize())
        ///     {
        ///         var registrations = DIContainer.Root.GetRegistrationsSnapshot();
        ///
        ///         DIContainer.Root
        ///                    .Register(Facility.Registrar, registrations)
        ///                    .Register(EFRepositoryRegistrar, registrations)
        ///                    ...
        ///                    ;
        ///     }
        /// ]]>
        /// </code>
        /// </remarks>
        public static IUnityContainer UnsafeRegister(
            this IUnityContainer container,
            ContainerRegistrar registrar,
            IDictionary <RegistrationLookup, ContainerRegistration> registrations,
            bool isTest = false)
        {
            if (registrar == null)
            {
                throw new ArgumentNullException(nameof(registrar));
            }

            return(registrar.UnsafeRegister(container, registrations, isTest));
        }