예제 #1
0
        /// <summary>
        /// Register service that will be created on resolve.
        /// </summary>
        /// <typeparam name="TInterface">Interface type.</typeparam>
        /// <typeparam name="TImplementation">Implementation type.</typeparam>
        /// <param name="registrationsBuilder">Registrations builder.</param>
        /// <returns>Registrations builder.</returns>
        public static RegistrationsBuilder RegisterOnResolve <TInterface, TImplementation>(this RegistrationsBuilder registrationsBuilder)
        {
            var builder = new RegistrationBuilder()
            {
                InterfaceType      = typeof(TInterface),
                ImplementationType = typeof(TImplementation),
            };

            registrationsBuilder.Register(builder.Build());
            return(registrationsBuilder);
        }
예제 #2
0
        /// <summary>
        /// Register instance.
        /// </summary>
        /// <typeparam name="TInterface">Interface type.</typeparam>
        /// <param name="registrationsBuilder">Registrations builder.</param>
        /// <param name="instance">Instance.</param>
        /// <param name="name">Name.</param>
        /// <param name="propertyInjections">Property injections.</param>
        /// <returns>Registrations builder.</returns>
        public static RegistrationsBuilder RegisterInstance <TInterface>(
            this RegistrationsBuilder registrationsBuilder,
            object instance,
            string name = null)
        {
            var builder = new RegistrationBuilder()
            {
                InterfaceType = typeof(TInterface),
                Name          = name,
                Instance      = instance,
            };

            registrationsBuilder.Register(builder.Build());
            return(registrationsBuilder);
        }