public Route GetRoute(ControllerContext context)
        {
            foreach (var route in routes)
                if (route.IsMatch(context))
                    return route;

            return null;
        }
Exemple #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);
 }
Exemple #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);
                }
            }
        }
Exemple #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();
        }
Exemple #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();
 }
Exemple #6
0
 public ActionResult ExecuteAction(ControllerContext context)
 {
     return action.Invoke(context);
 }
 public abstract void ExecuteResult(ControllerContext context);