예제 #1
0
        /// <summary>
        /// Register.
        /// </summary>
        /// <typeparam name="TInterface">Interface type.</typeparam>
        /// <typeparam name="TImplementation">Implementation type.</typeparam>
        /// <param name="registrationsBuilder">Registrations builder.</param>
        /// <param name="name">Name.</param>
        /// <param name="parameterInjections">Parameter injections.</param>
        /// <param name="propertyInjections">Property injections.</param>
        /// <returns>Registrations builder.</returns>
        public static RegistrationsBuilder Register <TInterface, TImplementation>(
            this RegistrationsBuilder registrationsBuilder,
            string name = null,
            IEnumerable <ParameterInjection> parameterInjections = null) where TImplementation : TInterface
        {
            var builder = new RegistrationBuilder()
            {
                InterfaceType      = typeof(TInterface),
                ImplementationType = typeof(TImplementation),
                Name       = name,
                Injections = new InjectionsBuilder
                {
                    ConstructorInjection = new ConstructorInjectionBuilder
                    {
                        Injections = parameterInjections,
                    }
                    .Build(),
                }
                .Build()
            };

            registrationsBuilder.AddRegistration(builder.Build());
            return(registrationsBuilder);
        }
예제 #2
0
 /// <summary>
 /// Register registration.
 /// </summary>
 /// <param name="registrationsBuilder">Registrations builder.</param>
 /// <param name="registration">Registration.</param>
 /// <returns>Registrations builder.</returns>
 public static RegistrationsBuilder Register(this RegistrationsBuilder registrationsBuilder, Registration registration)
 {
     return(registrationsBuilder.AddRegistration(registration));
 }