C# Класс Castle.MonoRail.Framework.ViewComponent

Base class for reusable UI Components.
Implementors should override ViewComponent.Initialize for implement proper initialization (if necessary). Also implement ViewComponent.Render as by default it will render a default view on [ViewFolderRoot]/components/[componentname].

You can also override ViewComponent.SupportsSection if your component supports neste sections (ie templates provided on the view that uses the view component.

Another way is to use the ViewComponentDetailsAttribute to specify a custom name and the sections supported.

Notice that view components can render strings or views on their folder. You can create sophisticate components with that mixture. Sections allow the users of your component to give it a block of content, usually customizing or definiting the content to be especially rendered by your component.

A very simplist view component that renders the time. public class ShowTime : ViewComponent { public override void Initialize() { } public override void Render() { RenderText("Time: " + DateTime.Now.ToString()); } }

This can be used from the view using the following syntax (NVelocity view engine)

#component(ShowTime)
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
Init ( IRailsEngineContext engineContext, IViewComponentContext componentContext ) : void

Invoked by the framework.

Initialize ( ) : void

Called by the framework once the component instance is initialized

Render ( ) : void

Called by the framework so the component can render its content

SupportsSection ( string name ) : bool

Implementor should return true only if the name is a known section the view component supports.

Защищенные методы

Метод Описание
CancelView ( ) : void

Cancels the view processing.

HasSection ( String sectionName ) : bool

Determines whether the current component declaration on the view has the specified section.

RenderBody ( ) : void

Renders the component body.

RenderBody ( TextWriter writer ) : void

Renders the body into the specified TextWriter

RenderSection ( String sectionName ) : void

Renders the the specified section

RenderSection ( String sectionName, TextWriter writer ) : void

Renders the the specified section

RenderSharedView ( String name ) : void

Specifies the shared view to be processed after the component has finished its processing. (A partial view shared by others views and usually in the root folder of the view directory).

RenderText ( String content ) : void

Renders the specified content back to the browser

RenderView ( String name ) : void

Specifies the view to be processed after the component has finished its processing.

RenderView ( String component, String name ) : void

Specifies the view to be processed after the component has finished its processing.

Приватные методы

Метод Описание
BindComponentParameters ( ) : void

Binds the component parameters.

BindParameter ( ViewComponentParamAttribute paramAtt, PropertyInfo property, IConverter converter ) : void
GetBaseViewPath ( ) : String
GetBaseViewPath ( String componentName ) : String

Описание методов

CancelView() защищенный Метод

Cancels the view processing.
protected CancelView ( ) : void
Результат void

HasSection() защищенный Метод

Determines whether the current component declaration on the view has the specified section.
protected HasSection ( String sectionName ) : bool
sectionName String Name of the section.
Результат bool

Init() публичный Метод

Invoked by the framework.
public Init ( IRailsEngineContext engineContext, IViewComponentContext componentContext ) : void
engineContext IRailsEngineContext Request context
componentContext IViewComponentContext ViewComponent context
Результат void

Initialize() публичный Метод

Called by the framework once the component instance is initialized
public Initialize ( ) : void
Результат void

Render() публичный Метод

Called by the framework so the component can render its content
public Render ( ) : void
Результат void

RenderBody() защищенный Метод

Renders the component body.
protected RenderBody ( ) : void
Результат void

RenderBody() защищенный Метод

Renders the body into the specified TextWriter
protected RenderBody ( TextWriter writer ) : void
writer System.IO.TextWriter The writer.
Результат void

RenderSection() защищенный Метод

Renders the the specified section
protected RenderSection ( String sectionName ) : void
sectionName String Name of the section.
Результат void

RenderSection() защищенный Метод

Renders the the specified section
protected RenderSection ( String sectionName, TextWriter writer ) : void
sectionName String Name of the section.
writer System.IO.TextWriter The writer.
Результат void

RenderSharedView() защищенный Метод

Specifies the shared view to be processed after the component has finished its processing. (A partial view shared by others views and usually in the root folder of the view directory).
protected RenderSharedView ( String name ) : void
name String
Результат void

RenderText() защищенный Метод

Renders the specified content back to the browser
protected RenderText ( String content ) : void
content String The content to render.
Результат void

RenderView() защищенный Метод

Specifies the view to be processed after the component has finished its processing.
protected RenderView ( String name ) : void
name String
Результат void

RenderView() защищенный Метод

Specifies the view to be processed after the component has finished its processing.
protected RenderView ( String component, String name ) : void
component String
name String
Результат void

SupportsSection() публичный Метод

Implementor should return true only if the name is a known section the view component supports.
public SupportsSection ( string name ) : bool
name string section being added
Результат bool