Пример #1
0
        public override void Process(TextWriter output, IRailsEngineContext context, Controller controller, string templateName)
        {
            string      fileName = GetFileName(templateName);
            AspViewBase view;
            TextWriter  viewOutput = output;
            AspViewBase layout     = null;

            if (controller.LayoutName != null)
            {
                layout     = GetLayout(output, context, controller);
                viewOutput = layout.ViewOutput;
            }
            view = GetView(fileName, viewOutput, context, controller);
            if (view == null)
            {
                throw new RailsException(string.Format(
                                             "Cannot find view '{0}'", fileName));
            }
            controller.PreSendView(view);
            view.Render();
            if (layout != null)
            {
                layout.SetParent(view);
                layout.Render();
            }
            controller.PostSendView(view);
        }
Пример #2
0
        /// <summary>
        /// Renders another view in place
        /// </summary>
        /// <param name="subViewName">The sub view's name</param>
        /// <param name="parameters">Parameters that can be sent to the sub view's Properties container</param>
        /// <param name="writer">The writer that will be used for the sub view's output</param>
        protected void OutputSubView(string subViewName, TextWriter writer, IDictionary parameters)
        {
            AspViewBase subView = viewEngine.GetView(GetRootedSubViewTemplate(subViewName), writer, Context, Controller, controllerContext);

            subView.Initialize(viewEngine, writer, Context, Controller, controllerContext, Properties);

            // bring parameters to the subview
            if (parameters != null)
            {
                foreach (string key in parameters.Keys)
                {
                    if (parameters[key] != null)
                    {
                        subView.Properties[key] = parameters[key];
                    }
                }
            }

            PushCurrentView();
            subView.Render();
            PopCurrentView();

            // allow CaptureFor generated content to bubble back up
            GatherBubblingPropertiesFrom(subView);
        }
Пример #3
0
        public override void ProcessContents(IRailsEngineContext context, Controller controller, string contents)
        {
            TextWriter  viewOutput = controller.Response.Output;
            AspViewBase layout     = null;

            if (controller.LayoutName != null)
            {
                layout     = GetLayout(viewOutput, context, controller);
                viewOutput = layout.ViewOutput;
            }
            viewOutput.Write(contents);
            if (layout != null)
            {
                layout.Render();
            }
        }
Пример #4
0
        /// <summary>
        /// Renders another view in place
        /// </summary>
        /// <param name="subViewName">The sub view's name</param>
        /// <param name="parameters">Parameters that can be sent to the sub view's Properties container</param>
        /// <param name="writer">The writer that will be used for the sub view's output</param>
        public void OutputSubView(string subViewName, TextWriter writer, IDictionary parameters)
        {
            string      subViewFileName = GetSubViewFileName(subViewName);
            AspViewBase subView         = _viewEngine.GetView(subViewFileName, writer, _context, _controller);

            if (parameters != null)
            {
                foreach (string key in parameters.Keys)
                {
                    if (parameters[key] != null)
                    {
                        subView.Properties[key] = parameters[key];
                    }
                }
            }
            subView.Render();
        }
Пример #5
0
        /// <summary>
        /// Renders another view in place
        /// </summary>
        /// <param name="subViewName">The sub view's name</param>
        /// <param name="parameters">Parameters that can be sent to the sub view's Properties container</param>
        /// <param name="writer">The writer that will be used for the sub view's output</param>
        protected void OutputSubView(string subViewName, TextWriter writer, IDictionary parameters)
        {
            string      subViewFileName = GetSubViewFileName(subViewName);
            AspViewBase subView         = viewEngine.GetView(subViewFileName, writer, context, controller, controllerContext);

            if (parameters != null)
            {
                foreach (string key in parameters.Keys)
                {
                    if (parameters[key] != null)
                    {
                        subView.Properties[key] = parameters[key];
                    }
                }
            }
            subView.Render();
            GatherBubblingPropertiesFrom(subView);
        }