Ejemplo n.º 1
0
        public static void DataBind(this Motor engine, Route route)
        {
            var list = new Dictionary<string, object>();

            var function = engine.RuntimeContext.Runnable.FunctionTable[route.Action];

            var instructions = engine.RuntimeContext.Runnable.Instructions;

            for (int i = function.EntryPoint; i < instructions.Length; i++)
            {
                var inst = instructions[i];

                if (inst.OpCode == OpCode.DCL)
                {
                    var value = route.Context.Request[inst.Operands[0].Value.ToString()] ?? string.Empty;

                    list.Add(inst.Operands[0].Value.ToString(), value);
                }

                if (inst.OpCode == OpCode.EMP) break;
            }

            foreach (var keypar in list.Reverse())
            {
                var op = new Operand(OperandType.Literal, keypar.Value);

                engine.RuntimeContext.Runnable.ParamStack.Push(op);
            }
        }
Ejemplo n.º 2
0
        public override void ProcessRequest(HttpContext context)
        {
            if (context.Request.Path == "/favicon.ico") return;

            var route = new Route(context);

            Execute(route);
        }
Ejemplo n.º 3
0
        public static object Url(params object[] parameters)
        {
            var area = parameters[0].ToString();
            var controller = parameters[1].ToString();
            var action = parameters.Length < 3? Route.Default: parameters[2].ToString();

            var url = new Route(area, controller, action, HttpContext.Current).Url;

            return url;
        }
Ejemplo n.º 4
0
        private SymbolTable ExecuteAction(Route route)
        {
            var script = ExtractContent(route.ControllerPhysicalPath);

            var engine = CreateEngine(script);

            engine.DataBind(route);

            engine.Executar(route.Action, null);

            return engine.RuntimeContext.Runnable.ScriptSymbolTable;
        }
Ejemplo n.º 5
0
        private void ExecuteView(Route route, SymbolTable model)
        {
            var fviewname = "page";

            var controllerScript = ExtractContent(route.ControllerPhysicalPath);

            route.View = ResolveView(route, model);

            var script = new DefaultScriptBuilder().Parse(ExtractContent(route.ViewPhysicalPath), fviewname)
                         + " " + controllerScript;

            var engine = CreateEngine(script, model.Refactor(fviewname));

            engine.Executar("page", new Infra(HttpContext.Current));
        }
Ejemplo n.º 6
0
        private void Execute(Route route)
        {
            var model = ExecuteAction(route);

            ExecuteView(route, model);
        }
Ejemplo n.º 7
0
        public string ResolveView(Route route, SymbolTable model)
        {
            var viewKey = string.Format("{0}_visao_0", route.Action);

            return model.ContainsKey(viewKey) ? model[viewKey].ToString(): route.Action;
        }