コード例 #1
0
        public WhenRunningInTheDebuggerTypedFactoryRegistrationExtraShould()
        {
            var sut = new TypedFactoryRegistration <int, DebuggerDisplayTestsBase>(c => null);

            _implementationType = sut.ImplementationType;
            GetDebuggerDisplay(sut);
        }
コード例 #2
0
        /// <summary>
        /// Registers a typed factory.
        /// </summary>
        /// <typeparam name="TFactory">
        /// The factory interface.
        /// </typeparam>
        /// <param name="container">
        /// The Unity container.
        /// </param>
        /// <returns>
        /// The holder object which facilitates the fluent interface.
        /// </returns>
        public static ITypedFactoryRegistration RegisterTypedFactory <TFactory>(this IUnityContainer container)
            where TFactory : class
        {
            var typedFactoryRegistration = new TypedFactoryRegistration <TFactory>(container);

            return(typedFactoryRegistration);
        }
コード例 #3
0
        /// <summary>
        /// Registers a typed factory.
        /// </summary>
        /// <typeparam name="TFactory">
        /// The <see cref="Type"/> of the factory interface.
        /// </typeparam>
        /// <typeparam name="TFactoryImpl">
        /// The concrete <see cref="Type"/> of the factory (TODO: This type should be automatically generated for the user).
        /// </typeparam>
        /// <param name="container">
        /// The Unity container.
        /// </param>
        /// <param name="factoryLifetimeManager">
        /// The <see cref="LifetimeManager"/> that controls the lifetime of the <see cref="TFactory"/> factory.
        /// </param>
        /// <returns>
        /// The holder object which facilitates the fluent interface.
        /// </returns>
        public static ITypedFactoryRegistration RegisterAutoFactory <TFactory, TFactoryImpl>(this IUnityContainer container, LifetimeManager factoryLifetimeManager)
            where TFactoryImpl : class, TFactory
        {
            var typedFactoryRegistration = new TypedFactoryRegistration <TFactory, TFactoryImpl>(container, factoryLifetimeManager);

            return(typedFactoryRegistration);
        }
コード例 #4
0
        /// <summary>
        /// Registers a typed factory.
        /// </summary>
        /// <param name="container">
        /// The Unity container.
        /// </param>
        /// <param name="factoryContractType">
        /// The factory interface.
        /// </param>
        /// <param name="name">
        /// Name that will be used to request the type.
        /// </param>
        /// <returns>
        /// The holder object which facilitates the fluent interface.
        /// </returns>
        public static ITypedFactoryRegistration RegisterTypedFactory(this IUnityContainer container,
                                                                     Type factoryContractType,
                                                                     string name)
        {
            var typedFactoryRegistration = new TypedFactoryRegistration(container, factoryContractType, name);

            return(typedFactoryRegistration);
        }
コード例 #5
0
        /// <summary>
        /// Accepts the <see cref="TypedFactoryRegistration{TImplementation}"/> to visit.
        /// </summary>
        /// <param name="registration">The <see cref="TypedFactoryRegistration{TImplementation}"/> to visit.</param>
        public void Accept(TypedFactoryRegistration <TImplementation> registration)
        {
            if (registration == null)
            {
                throw new ArgumentNullException(nameof(registration));
            }

            IComposition composition = new TypedFactoryComposition <TImplementation>(registration.Factory);

            _container.AddComposition(composition);
        }
コード例 #6
0
        /// <summary>
        /// Registers a typed factory.
        /// </summary>
        /// <typeparam name="TFactory">
        /// The factory interface.
        /// </typeparam>
        /// <param name="container">
        /// The Unity container.
        /// </param>
        /// <returns>
        /// The holder object which facilitates the fluent interface.
        /// </returns>
        public static ITypedFactoryRegistration RegisterTypedFactory <TFactory>(this IUnityContainer container)
            where TFactory : class
        {
            if (!typeof(TFactory).IsInterface)
            {
                throw new ArgumentException("The factory contract does not represent an interface!");
            }

            var typedFactoryRegistration = new TypedFactoryRegistration <TFactory>(container);

            return(typedFactoryRegistration);
        }
コード例 #7
0
        /// <summary>
        /// Registers a typed factory.
        /// </summary>
        /// <param name="factoryContractType">
        /// The factory interface.
        /// </param>
        /// <param name="container">
        /// The Unity container.
        /// </param>
        /// <returns>
        /// The holder object which facilitates the fluent interface.
        /// </returns>
        /// <exception cref="ArgumentException">
        /// Thrown when the <paramref name="factoryContractType"/> does not represent an interface type.
        /// </exception>
        public static ITypedFactoryRegistration RegisterTypedFactory(this IUnityContainer container,
                                                                     Type factoryContractType)
        {
            if (!factoryContractType.IsInterface)
            {
                throw new ArgumentException("The factory contract does not represent an interface!", "factoryContractType");
            }

            var typedFactoryRegistration = new TypedFactoryRegistration(container, factoryContractType);

            return(typedFactoryRegistration);
        }