Example #1
0
 public void GoNextStep(ControllerTypes ctype)
 {
     if (NextSteps.Contains(ctype))
     {
         var controller = controllerFactory.GetController(ctype);
         controller.Run();
     }
 }
        public async Task <MiddlewareData> InvokeAsync(MiddlewareData data, IMiddlewaresChain chain)
        {
            var controller = _controllerFactory.GetController(data);

            var newData = await controller.InvokeAsync(data);

            return(await chain.NextAsync(newData));
        }
Example #3
0
        public void RunInteractive()
        {
            new HelpController().PrintHelp();

            bool running = true;

            while (running)
            {
                var line       = _io.ReadLine();
                var route      = _router.ParseCommand(line);
                var controller = _controllerFactory.GetController(route);
                InvokeRoute(controller, route);
            }
        }
 public BannerAdministrator(IControllerFactory pFactory): base(pFactory)
 {
     InitializeComponent();
     var aux = pFactory.GetController<ManageBannerHandler>();
     this.Load += BannerAdministrator_Load;
 }
        public ActionContext Resolve(RequestContext requestContext)
        {
            foreach (Route route in _routeCollection)
            {
                // TODO: Improve tokenizing
                var routePattern = route.RoutePath
                                   .Replace("/{controller}", "(?:/(?<controller>[a-zA-Z0-9-.]+)?)?")
                                   .Replace("/{action}", "(?:/(?<action>[a-zA-Z0-9-.]+)?)?");

                var routeRegex = new Regex(routePattern, RegexOptions.IgnoreCase);

                var match = routeRegex.Match(requestContext.Url);

                if (match.Success)
                {
                    var controllerName = match.Groups["controller"].Value;

                    var controllerType = _controllerFactory.GetController(controllerName);

                    string[] actions = { };

                    if (match.Groups["action"].Success)
                    {
                        actions = new[] { match.Groups["action"].Value };
                    }
                    else
                    {
                        switch (requestContext.Method)
                        {
                        case Method.GET:
                            actions = new[] { "index", "get" };
                            break;

                        case Method.POST:
                            actions = new[] { "post" };
                            break;

                        case Method.PUT:
                            actions = new[] { "put" };
                            break;

                        case Method.DELETE:
                            actions = new[] { "delete" };
                            break;

                        case Method.OPTIONS:
                            actions = new[] { "options" };
                            break;

                        case Method.HEAD:
                            actions = new[] { "head" };
                            break;

                        case Method.MERGE:
                            actions = new[] { "merge" };
                            break;
                        }
                    }


                    foreach (var action in actions)
                    {
                        var methodInfo = GetMatchingAction(requestContext.Method, controllerType, action);

                        if (methodInfo != null)
                        {
                            var actionContext = new ActionContext()
                            {
                                ActionMethod   = methodInfo,
                                ControllerType = controllerType,
                                Request        = requestContext
                            };

                            return(actionContext);
                        }
                    }
                }
            }

            return(null);
        }
 public CampaignAdministrator(IControllerFactory pFactory) : base(pFactory)
 {
     InitializeComponent();
     this.iController = pFactory.GetController <ManageCampaignHandler>();
     this.Load       += CampaignAdministrator_Load;
 }