コード例 #1
0
        public MainWindow()
        {
            // Setup
            InitializeComponent();

            IoCRegistration.Initialise();
            cVm = IoCRegistration.Resolve <ICommunityViewModel>();

            ShowDefaultwWindows();

            cmdProc = cVm.DwellerCommandProcessor;

            DataContext = cVm;

            // Connect the buttons
            cmdProc.NewDwellerCreated  += DwellerCreated;
            cmdProc.NewBuildingCreated += BuildingCreated;

            // Update our bounds
            Grid_SizeChanged(null, null);

            // add some dwellers and stuff
            AddInitialHome();
            AddInitialCafe();
            AddInitialWorkplace();
            AddInitialDwellers();
        }
コード例 #2
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            Mapper.Initialize(Mappings.CreateMappings);

            var builder = new ContainerBuilder();

            IoCRegistration.RegisterTypes(builder);

            // Register your MVC controllers. (MvcApplication is the name of
            // the class in Global.asax.)
            builder.RegisterControllers(typeof(MvcApplication).Assembly);

            // OPTIONAL: Register model binders that require DI.
            builder.RegisterModelBinders(typeof(MvcApplication).Assembly);
            builder.RegisterModelBinderProvider();

            // OPTIONAL: Register web abstractions like HttpContextBase.
            builder.RegisterModule <AutofacWebTypesModule>();

            // OPTIONAL: Enable property injection in view pages.
            builder.RegisterSource(new ViewRegistrationSource());

            // OPTIONAL: Enable property injection into action filters.
            builder.RegisterFilterProvider();

            // Set the dependency resolver to be Autofac.
            var container = builder.Build();

            DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
        }
コード例 #3
0
        protected void Application_Start()
        {
            GlobalConfiguration.Configure(WebApiConfig.Register);

            Mapper.Initialize(Mappings.CreateMappings);

            var builder = new ContainerBuilder();

            IoCRegistration.RegisterTypes(builder);

            // Get your HttpConfiguration.
            var config = GlobalConfiguration.Configuration;

            // Register your Web API controllers.
            builder.RegisterApiControllers(Assembly.GetExecutingAssembly());

            // OPTIONAL: Register the Autofac filter provider.
            builder.RegisterWebApiFilterProvider(config);

            // OPTIONAL: Register the Autofac model binder provider.
            builder.RegisterWebApiModelBinderProvider();

            // Set the dependency resolver to be Autofac.
            var container = builder.Build();

            config.DependencyResolver = new AutofacWebApiDependencyResolver(container);
        }