public TemplateContext(HttpContextBase context,
			TemplateRenderingBase template, object model)
		{
			_context = context;
			_template = template;
			_model = model;
		}
 public ControllerContext(HttpContextBase context, 
     RouteData routeData, ControllerBase controller)
     : base(context, routeData)
 {
     Precondition.Require(controller, () => Error.ArgumentNull("controller"));
     _controller = controller;
 }
Exemplo n.º 3
0
		public static void Push(HttpContextBase context, ITemplateFile template)
		{
			Precondition.Require(context, () => Error.ArgumentNull("context"));
			Precondition.Require(template, () => Error.ArgumentNull("template"));

			Stack(context).Push(template);
		}
        protected virtual bool Match(HttpContextBase context, Route route,
            ValueDictionary values, RouteDirection direction)
        {
            Precondition.Require(values, () => Error.ArgumentNull("values"));

            string value = values.GetValue<string>(_parameterName) ?? String.Empty;
            return _pattern.IsMatch(value);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Initializes a new instance of the 
        /// <see cref="RequestContext"/> class
        /// </summary>
        /// <param name="context">An <see cref="HttpContextBase"/> of the current request</param>
        /// <param name="routeData">The route parameter dictionary</param>
        public RequestContext(HttpContextBase context, RouteData routeData)
        {
            Precondition.Require(context, () => Error.ArgumentNull("context"));
            Precondition.Require(routeData, () => Error.ArgumentNull("routeData"));

            _context = context;
            _routeData = routeData;
        }
        protected virtual bool Match(HttpContextBase context, Route route, 
            ValueDictionary values, RouteDirection direction)
        {
            if (direction == RouteDirection.UrlGeneration)
                return true;

            Precondition.Require(context, () => Error.ArgumentNull("context"));
            return ((context.Request.HttpMethod & _methods) > 0);
        }
Exemplo n.º 7
0
 public ViewContext(HttpContextBase context, RouteData routeData, 
     ControllerBase controller, IView view, ViewDataDictionary viewData, 
     TempDataDictionary tempData)
     : base(context, routeData, controller)
 {
     _view = view;
     _viewData = viewData;
     _tempData = tempData;
 }
Exemplo n.º 8
0
		private static Stack<ITemplateFile> Stack(HttpContextBase context)
		{
			Stack<ITemplateFile> stack = (context.Items[_contextKey] as Stack<ITemplateFile>);
			if (stack == null)
			{
				stack = new Stack<ITemplateFile>();
				context.Items[_contextKey] = stack;
			}
			return stack;
		}
        protected override bool Validate(HttpContextBase context)
        {
            bool isAuthorized = base.Validate(context);
            if (!isAuthorized)
                return false;

            if (_users == null || _users.Length < 1)
                return true;

            string userName = context.User.Identity.Name;
            return _users.Any(s => s.Equals(userName, StringComparison.OrdinalIgnoreCase));
        }
        protected override void Write(HttpContextBase context)
        {
            Stream output = context.Response.OutputStream;
            using (_stream)
            {
                byte[] buffer = new byte[4096];
                int count = 0;

                while ((count = _stream.Read(buffer, 0, 4096)) > 0)
                    output.Write(buffer, 0, count);
            }
        }
        protected override bool Validate(HttpContextBase context)
        {
            bool isAuthorized = base.Validate(context);
            if (!isAuthorized)
                return false;

            if (_roles == null || _roles.Length < 1)
                return true;

            IPrincipal user = context.User;
            return _roles.Any(role => user.IsInRole(role));
        }
Exemplo n.º 12
0
        private static string ResolvePath(HttpContextBase context, string virtualUrl)
        {
			if (!virtualUrl.StartsWith("~/", StringComparison.Ordinal))
				return virtualUrl;
   
			virtualUrl = virtualUrl.Remove(0, 2);
            string appPath = context.Request.ApplicationPath;

            if (String.IsNullOrEmpty(appPath))
                appPath = "/";

            if (!appPath.EndsWith("/"))
                appPath = String.Concat(appPath, "/");

            return String.Concat(appPath, virtualUrl);
        }
Exemplo n.º 13
0
        protected override void Write(HttpContextBase context)
        {
            if (_contentEncoding != null)
                context.Response.ContentEncoding = _contentEncoding;

            string filePath = context.Server.MapPath(
				ResolvePath(context, _path));

            FileInfo fi = new FileInfo(filePath);

            if (fi.Exists)
            {
                context.Response.AddHeader("Last-Modified",
                    fi.LastWriteTimeUtc.ToString("r"));
                context.Response.AddHeader("Content-Length",
                    fi.Length.ToString());
            }
            context.Response.TransmitFile(filePath);
        }
Exemplo n.º 14
0
 bool IRouteConstraint.Match(HttpContextBase context, Route route,
     ValueDictionary values, RouteDirection direction)
 {
     return Match(context, route, values, direction);
 }
Exemplo n.º 15
0
 public BlockRenderer(HttpContextBase context)
 {
     Precondition.Require(context, () => Error.ArgumentNull("context"));
     _context = context;
 }
Exemplo n.º 16
0
        /// <summary>
        /// Gets the <see cref="RouteData"/> for 
        /// the current <see cref="HttpContextBase"/>.
        /// </summary>
        /// <param name="context">The <see cref="HttpContextBase"/> 
        /// containing the incoming request.</param>
		/// <param name="variables">The <see cref="ValueDictionary"/> 
		/// containing the route variable values.</param>
        public abstract RouteData GetRouteData(HttpContextBase context, ValueDictionary variables);
Exemplo n.º 17
0
		public static ITemplateFile CurrentTemplate(HttpContextBase context)
		{
			Precondition.Require(context, () => Error.ArgumentNull("context"));
			return Stack(context).FirstOrDefault();
		}
Exemplo n.º 18
0
		public static ITemplateFile Pop(HttpContextBase context)
		{
			Precondition.Require(context, () => Error.ArgumentNull("context"));
			return Stack(context).Pop();
		}