Beispiel #1
0
        public AspViewBase CreateView(Type type, TextWriter output, IRailsEngineContext context, Controller controller)
        {
            AspViewBase view = (AspViewBase)FormatterServices.GetUninitializedObject(type);

            view.Initialize(this, output, context, controller);
            return(view);
        }
        /// <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);
        }