public void Render(ViewContext context, TextWriter writer)
		{
			Precondition.Require(context, () => Error.ArgumentNull("context"));
			Type type = BuildManager.GetCompiledType(ViewPath);
			object instance = null;

			if (type != null)
				instance = Activator.Create(context, type);

			Precondition.Require(instance, () => Error.CouldNotCreateView(ViewPath));
			RenderView(context, writer, instance);
		}
예제 #2
0
        /// <summary>
        /// Renders the view page to the response.
        /// </summary>
        public virtual void RenderView(ViewContext context)
        {
            _viewContext = context;
            InitHelpers(context);
            ID = Guid.NewGuid().ToString();

			context.Context.Server.Execute(HttpHandlerWrapper.Wrap(this), _output, true);
        }
예제 #3
0
        /// <summary>
        /// Instantiates and initializes the Ajax, Html, and Url properties.
        /// </summary>
        public virtual void InitHelpers(ViewContext context)
        {
			Precondition.Require(context, 
				() => Mvc.Error.ArgumentNull("context"));

            SetContentType(context.Context);
            _parameters = context.Context.Request.Parameters;
            _html = new HtmlHelper(context);
            _url = new UrlHelper(context);
            _ajax = new AjaxHelper(context);
            _validation = new ValidationHelper(context);
        }
예제 #4
0
        /// <summary>
        /// When called by the action invoker, renders the view to the response.
        /// </summary>
        /// <param name="context"></param>
        public override void Execute(ControllerContext context)
        {
            Precondition.Require(context, () => Error.ArgumentNull("context"));
            if (String.IsNullOrEmpty(ViewName))
                ViewName = context.RouteData.GetRequiredValue<string>("action");

            ViewEngineResult result = null;
            if (View == null)
            {
                result = FindView(context);
                View = result.View;
            }

            ViewContext vc = new ViewContext(context, View, ViewData, TempData);
            vc.ModelState = ModelState;

            try
            {
                View.Render(vc, context.Context.Response.Output);
            }
            finally
            {
                if(result != null)
                    result.Engine.ReleaseView(context, View);
            }
        }
		protected abstract void RenderView(ViewContext context, TextWriter writer, object instance);
 public ValidationHelper(ViewContext context)
 {
     Precondition.Require(context, () => Error.ArgumentNull("context"));
     _context = context;
 }
        public virtual void RenderView(ViewContext context)
        {
            context.Context.Response.Cache.SetExpires(DateTime.Now);
            ControlContainerPage page = new ControlContainerPage(this);
			page.Output = _output;

			string contentType = context.Context.Response.ContentType;
			page.RenderView(context);

			context.Context.Response.ContentType = contentType;
        }