public IController CreateController(RequestContext requestContext, string controllerName)
        {
            if (controllerName.ToLower().StartsWith("proteintracker"))
            {
                var repository = new ProteinRespository();
                var service    = new ProteinTrackingService(repository);
                var controller = new ProteinTrackerController(service);
                return(controller);
            }
            var defaultFactory = new DefaultControllerFactory();

            return(defaultFactory.CreateController(requestContext, controllerName));
        }
Ejemplo n.º 2
0
        public IController CreateController(RequestContext requestContext, string controllerName)
        {
            if (controllerName.ToLower().StartsWith("proteintracker"))
            {
                //Create an instance of the ProteinTrackingService
                var service = new ProteinTrackingService();
                //Pass this new instance into the creation of the controller.  Now remember, that even though this is a concrete instance
                //the controller can accept anything derived from IProteinTrackingService
                //It doesn't care what the class is, as long as it's implementing this interface
                var controller = new ProteinTrackerController(service);
                return(controller);
            }

            //For all other types of Controller, we're just going to let it do what the default is
            var defaultController = new DefaultControllerFactory();

            return(defaultController.CreateController(requestContext, controllerName));
        }