Ejemplo n.º 1
0
        public Route GetRoute(ControllerContext context)
        {
            foreach (var route in routes)
                if (route.IsMatch(context))
                    return route;

            return null;
        }
Ejemplo n.º 2
0
 public override void ExecuteResult(ControllerContext context)
 {
     context.Response.ClearContent();
     context.Response.ContentType = contentType;
     if (!String.IsNullOrEmpty(filename))
         context.Response.AddHeader("Content-Disposition", new ContentDisposition { FileName = filename }.ToString());
     context.Response.OutputStream.Write(content, 0, content.Length);
 }
Ejemplo n.º 3
0
        public override void ExecuteResult(ControllerContext context)
        {
            foreach (var resource in Assembly.GetExecutingAssembly().GetManifestResourceNames())
            {
                if (resource.ToLower().EndsWith((name + ".view").ToLower()))
                {
                    string view;
                    using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resource))
                    using (var reader = new StreamReader(stream))
                        view = reader.ReadToEnd();

                    RenderView(view, context);
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Renders the view.
        /// </summary>
        /// <param name="view">The view.</param>
        /// <param name="context">The context.</param>
        private void RenderView(string view, ControllerContext context)
        {
            context["request"] = context.Request;
            context["response"] = context.Response;
            context["url"] = context.Request.RawUrl;
            context["urls"] = new Urls();
            context["util"] = new UtilWrapper();
            context["macros"] = new Macros();
            context["data"] = new Data();
            context["site"] = SiteSettings.Get();

            context.Response.ClearContent();
            context.Response.ContentType = contentType;
            if (!String.IsNullOrEmpty(filename))
                context.Response.AddHeader("Content-Disposition", new ContentDisposition { FileName = filename }.ToString());
            TemplateEngine.Evaluate(context.Response.Output, view, context);
            context.Response.End();
        }
Ejemplo n.º 5
0
 public bool IsMatch(ControllerContext context)
 {
     // TODO: Convert URL to consistent format
     var requestPath = (context.Request.AppRelativeCurrentExecutionFilePath + context.Request.PathInfo);
     return context.Request.HttpMethod == method && requestPath.ToLower() == url.ToLower();
 }
Ejemplo n.º 6
0
 public ActionResult ExecuteAction(ControllerContext context)
 {
     return action.Invoke(context);
 }
Ejemplo n.º 7
0
 public abstract void ExecuteResult(ControllerContext context);