예제 #1
0
        /// <summary>
        /// Adds rule to include certain types that satisfy specified type filter
        /// and register them using specified registration options
        /// </summary>
        /// <param name="typeFilter">Type filter.</param>
        /// <param name="registrationOptions">RegistrationOptions options.</param>
        /// <returns>Auto registration</returns>
        public virtual IAutoRegistration Include(Predicate<Type> typeFilter, IRegistrationOptions registrationOptions)
        {
            if (typeFilter == null)
            {
                throw new ArgumentNullException("typeFilter");
            }

            if (registrationOptions == null)
            {
                throw new ArgumentNullException("registrationOptions");
            }

            registrationEntries.Add(new RegistrationEntry(
                                         typeFilter,
                                         (t, c) =>
                                         {
                                             registrationOptions.Type = t;
                                             foreach (var contract in registrationOptions.Interfaces)
                                             {
                                                 c.RegisterType(
                                                     contract,
                                                     t,
                                                     registrationOptions.Name,
                                                     registrationOptions.LifetimeManager);
                                             }
                                         },
                                         container));
            return this;
        }
예제 #2
0
        /// <summary>
        /// Adds rule to include certain types that satisfy specified type filter
        /// and register them using specified registration options
        /// </summary>
        /// <param name="typeFilter">Type filter.</param>
        /// <param name="registrationOptions">RegistrationOptions options.</param>
        /// <returns>Auto registration</returns>
        public virtual IAutoRegistration Include(
            Predicate <Type> typeFilter,
            IRegistrationOptions registrationOptions)
        {
            if (typeFilter == null)
            {
                throw new ArgumentNullException("typeFilter");
            }
            if (registrationOptions == null)
            {
                throw new ArgumentNullException("registrationOptions");
            }

            _registrationEntries.Add(new RegistrationEntry(
                                         typeFilter,
                                         (t, c) =>
            {
                registrationOptions.Type = t;
                foreach (var contract in registrationOptions.Interfaces)
                {
                    c.RegisterType(
                        contract,
                        t,
                        registrationOptions.Name,
                        registrationOptions.LifetimeManager);
                }
            },
                                         _container));
            return(this);
        }
예제 #3
0
        /// <summary>
        /// Adds rule to include certain types that satisfy specified type filter
        /// and register them using specified registration options
        /// </summary>
        /// <param name="typeFilter">Type filter.</param>
        /// <param name="registrationOptions">RegistrationOptions options.</param>
        /// <returns>Auto registration</returns>
        public virtual IAutoRegistration Include(
            Predicate <Type> typeFilter,
            IRegistrationOptions registrationOptions)
        {
            if (typeFilter == null)
            {
                throw new ArgumentNullException("typeFilter");
            }
            if (registrationOptions == null)
            {
                throw new ArgumentNullException("registrationOptions");
            }

            _registrationEntries.Add(new RegistrationEntry(
                                         typeFilter,
                                         (t, c) =>
            {
                registrationOptions.Type = t;
                foreach (var contract in registrationOptions.Interfaces)
                {
                    c.Add(new ServiceDescriptor(
                              contract,
                              t,
                              registrationOptions.ServiceLifetime));
                }
            },
                                         _services));
            return(this);
        }