Ejemplo n.º 1
0
        /// <summary>
        /// Registers a module to the container.
        /// </summary>
        /// <typeparam name="TModule">Type of module.</typeparam>
        /// <param name="builder"><see cref="ContainerBuilder"/> instance.</param>
        /// <param name="handler"><see cref="RegistrationHandler"/> instance.</param>
        /// <returns>Returns <see cref="ContainerBuilder"/> instance.</returns>
        public static ContainerBuilder RegisterModule <TModule>(this ContainerBuilder builder, RegistrationHandler handler)
            where TModule : IModule, new()
        {
            builder.RegisterModule <TModule>();

            if (handler.IsNullOrDefault())
            {
                return(builder);
            }

            if (handler.RegisterTypeAsInstancePerDependency.IsNullOrDefault())
            {
                return(builder);
            }

            handler.RegisterTypeAsInstancePerDependency.Invoke(builder);

            return(builder);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="FunctionFactory"/> class.
 /// </summary>
 /// <param name="handler"><see cref="RegistrationHandler"/> instance.</param>
 public FunctionFactory(RegistrationHandler handler = null)
 {
     this._container = new ContainerBuilder()
                       .RegisterModule <AppModule>(handler)
                       .Build();
 }