コード例 #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);
        }
コード例 #2
0
        public virtual AspViewBase GetView(string fileName, TextWriter output, IRailsEngineContext context, Controller controller)
        {
            fileName = NormalizeFileName(fileName);
            string className = GetClassName(fileName);

            if (needsRecompiling)
            {
                needsRecompiling = false;
                RecompileViews();
            }

            Type viewType = compilations[className] as Type;

            if (viewType == null)
            {
                throw new RailsException("Cannot find view type for {0}.", fileName);
            }

            // create a view instance
            AspViewBase theView = null;

            try
            {
                theView = CreateView(viewType, output, context, controller);
            }
            catch (Exception ex)
            {
                throw new RailsException(string.Format(
                                             "Cannot create view instance from '{0}'.",
                                             fileName), ex);
            }
            return(theView);
        }
コード例 #3
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);
        }
コード例 #4
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);
        }
コード例 #5
0
        public AspViewBase CreateView(Type type, TextWriter output, IRailsEngineContext context, Controller controller)
        {
            ConstructorInfo constructor = (ConstructorInfo)constructors[type];
            AspViewBase     self        = (AspViewBase)FormatterServices.GetUninitializedObject(type);

            constructor.Invoke(self, new object[] { this, output, context, controller });
            return(self);
        }
コード例 #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ViewComponentContext"/> class.
 /// </summary>
 /// <param name="parent">The parent.</param>
 /// <param name="body">The body.</param>
 /// <param name="name">The name.</param>
 /// <param name="writer">The text writer.</param>
 /// <param name="parameters">The parameters.</param>
 public ViewComponentContext(AspViewBase parent, ViewComponentSectionRendereDelegate body,
                             string name, TextWriter writer, IDictionary parameters)
 {
     this.parent         = parent;
     this.body           = body;
     componentName       = name;
     default_writer      = writer;
     componentParameters = parameters;
 }
コード例 #7
0
		/// <summary>
		/// Initializes a new instance of the <see cref="ViewComponentContext"/> class.
		/// </summary>
		/// <param name="parent">The parent.</param>
		/// <param name="body">The body.</param>
		/// <param name="name">The name.</param>
		/// <param name="writer">The text writer.</param>
		/// <param name="parameters">The parameters.</param>
		public ViewComponentContext(AspViewBase parent, ViewComponentSectionRendereDelegate body,
										 string name, TextWriter writer, IDictionary parameters)
		{
			this.parent = parent;
			this.body = body;
			componentName = name;
			default_writer = writer;
			componentParameters = parameters;
		}
コード例 #8
0
        protected virtual AspViewBase GetLayout(TextWriter output, IRailsEngineContext context, Controller controller)
        {
            string      layoutTemplate = "layouts\\" + controller.LayoutName;
            string      layoutFileName = GetFileName(layoutTemplate);
            AspViewBase layout         = null;

            layout            = GetView(layoutFileName, output, context, controller);
            layout.ViewOutput = new StringWriter();
            return(layout);
        }
コード例 #9
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();
            }
        }
コード例 #10
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();
        }
コード例 #11
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);
        }
コード例 #12
0
ファイル: AspViewBase.cs プロジェクト: mgagne-atman/Projects
		/// <summary>
		/// Sets a view's parent view. Used in layouts
		/// </summary>
		/// <param name="view">The view's parent</param>
		internal void SetParent(AspViewBase view)
		{
			parentView = view;
		}
コード例 #13
0
ファイル: AspViewBase.cs プロジェクト: mgagne-atman/Projects
			public ReturnOutputStreamToInitialWriter(TextWriter initialWriter, AspViewBase parent)
			{
				this.initialWriter = initialWriter;
				this.parent = parent;
			}
コード例 #14
0
 public ReturnOutputStreamToInitialWriter(TextWriter initialWriter, AspViewBase parent)
 {
     this.initialWriter = initialWriter;
     this.parent        = parent;
 }
コード例 #15
0
 /// <summary>
 /// Sets a view's parent view. Used in layouts
 /// </summary>
 /// <param name="view">The view's parent</param>
 internal void SetParent(AspViewBase view)
 {
     _parentView = view;
 }
コード例 #16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ViewComponentContext"/> class.
 /// </summary>
 /// <param name="parent">The parent.</param>
 /// <param name="body">The body.</param>
 /// <param name="name">The name.</param>
 /// <param name="writer">The text writer.</param>
 /// <param name="arguments">The arguments.</param>
 public ViewComponentContext(AspViewBase parent, ViewComponentSectionRendereDelegate body,
                             string name, TextWriter writer, params object[] arguments)
     : this(parent, body, name, writer, (IDictionary)Utilities.ConvertArgumentsToParameters(arguments))
 {
 }
コード例 #17
0
		/// <summary>
		/// Initializes a new instance of the <see cref="ViewComponentContext"/> class.
		/// </summary>
		/// <param name="parent">The parent.</param>
		/// <param name="body">The body.</param>
		/// <param name="name">The name.</param>
		/// <param name="writer">The text writer.</param>
		/// <param name="arguments">The arguments.</param>
		public ViewComponentContext(AspViewBase parent, ViewComponentSectionRendereDelegate body,
										 string name, TextWriter writer, params object[] arguments)
			: this(parent, body, name, writer, (IDictionary)Utilities.ConvertArgumentsToParameters(arguments)) { }