示例#1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllersWithViews();
            services.AddHttpClient();

            // Sets up the basic configuration that for integrating Simple Injector with
            // ASP.NET Core by setting the DefaultScopedLifestyle, and setting up auto
            // cross wiring.
            services.AddSimpleInjector(_diConfig.Container, options =>
            {
                // AddAspNetCore() wraps web requests in a Simple Injector scope and
                // allows request-scoped framework services to be resolved.
                options.AddAspNetCore()

                // Ensure activation of a specific framework type to be created by
                // Simple Injector instead of the built-in configuration system.
                // All calls are optional. You can enable what you need. For instance,
                // PageModels and TagHelpers are not needed when you build a Web API.
                .AddControllerActivation()
                .AddViewComponentActivation()
                .AddPageModelActivation()
                .AddTagHelperActivation();
            });

            _diConfig.Register();
        }
示例#2
0
 protected void Application_Start()
 {
     AreaRegistration.RegisterAllAreas();
     DiConfig.Register();
     FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     BundleConfig.RegisterBundles(BundleTable.Bundles);
 }
 /// <summary>
 /// Registers the type mappings with the Unity container.
 /// </summary>
 /// <param name="container">The unity container to configure.</param>
 /// <remarks>
 /// There is no need to register concrete types such as controllers or
 /// API controllers (unless you want to change the defaults), as Unity
 /// allows resolving a concrete type even if it was not previously
 /// registered.
 /// </remarks>
 public static void RegisterTypes(IUnityContainer container)
 {
     DiConfig.Register();
 }