public void RenderComponent(ComponentData componentData)
        {
            var componentContext = new NHamlViewComponentContext(this, componentData.Body, componentData.Name, Output.TextWriter, (IDictionary)componentData.Parameters);
            foreach (var section in componentData.Sections)
            {
                componentContext.RegisterSection(section.Key, section.Value);
            }
            AddViewComponentProperties(componentContext.ComponentParameters);
			var componentFactory = (IViewComponentFactory) ViewContext.GetService(typeof(IViewComponentFactory));
			var component = componentFactory.Create(componentData.Name);
            
			component.Init(ViewContext, componentContext);
			component.Render();
			if (componentContext.ViewToRender != null)
			{
				OutputSubView("/" + componentContext.ViewToRender, componentContext.ComponentParameters);
			}
			RemoveViewComponentProperties(componentContext.ComponentParameters);
		}
示例#2
0
        public void RenderComponent(ComponentData componentData)
        {
            var componentContext = new NHamlViewComponentContext(this, componentData.Body, componentData.Name, Output.TextWriter, (IDictionary)componentData.Parameters);

            foreach (var section in componentData.Sections)
            {
                componentContext.RegisterSection(section.Key, section.Value);
            }
            AddViewComponentProperties(componentContext.ComponentParameters);
            var componentFactory = (IViewComponentFactory)ViewContext.GetService(typeof(IViewComponentFactory));
            var component        = componentFactory.Create(componentData.Name);

            component.Init(ViewContext, componentContext);
            component.Render();
            if (componentContext.ViewToRender != null)
            {
                OutputSubView("/" + componentContext.ViewToRender, componentContext.ComponentParameters);
            }
            RemoveViewComponentProperties(componentContext.ComponentParameters);
        }