C# Class Castle.MonoRail.Views.Brail.BrailBase

Base class for all the view scripts, this is the class that is responsible for support all the behind the scenes magic such as variable to PropertyBag trasnlation, resources usage, etc.
Show file Open project: nats/castle-1.0.3-mono Class Usage Examples

Protected Properties

Property Type Description
__controller Castle.MonoRail.Framework.Controller
childOutput System.IO.TextWriter
context IRailsEngineContext
parent BrailBase
viewEngine BooViewEngine

Public Methods

Method Description
AddProperty ( string name, object item ) : void

Note that this will overwrite any existing property.

AddViewComponentProperties ( IDictionary newProperties ) : void

Adds the view component newProperties. This will be included in the parameters searching, note that this override the current parameters if there are clashing. The search order is LIFO

BrailBase ( BooViewEngine viewEngine, TextWriter output, IRailsEngineContext context, Controller __controller ) : System.Diagnostics

Initializes a new instance of the BrailBase class.

GetParameter ( string name ) : object

this is called by ReplaceUnknownWithParameters step to create a more dynamic experiance any uknown identifier will be translate into a call for GetParameter('identifier name'). This mean that when an uknonwn identifier is in the script, it will only be found on runtime.

GetSubViewFilename ( string subviewName ) : string

Get the sub view file name, if the subview starts with a '/' then the filename is considered relative to ViewDirRoot otherwise, it's relative to the current script directory

IsDefined ( string name ) : bool

Allows to check that a parameter was defined

OutputSubView ( string subviewName ) : string

Output the subview to the client, this is either a relative path "SubView" which is relative to the current /script/ or an "absolute" path "/home/menu" which is actually relative to ViewDirRoot

OutputSubView ( string subviewName, IDictionary parameters ) : string

Similiar to the OutputSubView(string) function, but with a bunch of parameters that are used just for this subview. This parameters are /not/ inheritable.

OutputSubView ( string subviewName, TextWriter writer, IDictionary parameters ) : void

Outputs the sub view to the writer

RemoveViewComponentProperties ( IDictionary propertiesToRemove ) : void

Removes the view component properties, so they will no longer be visible to the views.

RenderComponent ( string componentName ) : void
RenderComponent ( string componentName, IDictionary parameters ) : void
Run ( ) : void

Runs this instance, this is generated by the script

SetOutputStream ( TextWriter newOutputStream ) : IDisposable

This is required because we may want to replace the output stream and get the correct behavior from components call RenderText() or RenderSection()

SetParent ( BrailBase myParent ) : void

Sets the parent.

TryGetParameter ( string name ) : object

this is called by ReplaceUnknownWithParameters step to create a more dynamic experiance any uknown identifier with the prefix of ? will be translated into a call for TryGetParameter('identifier name without the ? prefix'). This method will return null if the value it not found.

Private Methods

Method Description
GetParameterInternal ( string name ) : ParameterSearch

Gets the parameter - implements the logic for searching parameters.

InitProperties ( IRailsEngineContext myContext, Controller myController ) : void

Initialize all the properties that a script may need One thing to note here is that resources are wrapped in ResourceToDuck wrapper to enable easy use by the script

Method Details

AddProperty() public method

Note that this will overwrite any existing property.
public AddProperty ( string name, object item ) : void
name string
item object
return void

AddViewComponentProperties() public method

Adds the view component newProperties. This will be included in the parameters searching, note that this override the current parameters if there are clashing. The search order is LIFO
public AddViewComponentProperties ( IDictionary newProperties ) : void
newProperties IDictionary The newProperties.
return void

BrailBase() public method

Initializes a new instance of the BrailBase class.
public BrailBase ( BooViewEngine viewEngine, TextWriter output, IRailsEngineContext context, Controller __controller ) : System.Diagnostics
viewEngine BooViewEngine The view engine.
output System.IO.TextWriter The output.
context IRailsEngineContext The context.
__controller Castle.MonoRail.Framework.Controller The controller.
return System.Diagnostics

GetParameter() public method

this is called by ReplaceUnknownWithParameters step to create a more dynamic experiance any uknown identifier will be translate into a call for GetParameter('identifier name'). This mean that when an uknonwn identifier is in the script, it will only be found on runtime.
public GetParameter ( string name ) : object
name string
return object

GetSubViewFilename() public method

Get the sub view file name, if the subview starts with a '/' then the filename is considered relative to ViewDirRoot otherwise, it's relative to the current script directory
public GetSubViewFilename ( string subviewName ) : string
subviewName string
return string

IsDefined() public method

Allows to check that a parameter was defined
public IsDefined ( string name ) : bool
name string
return bool

OutputSubView() public method

Output the subview to the client, this is either a relative path "SubView" which is relative to the current /script/ or an "absolute" path "/home/menu" which is actually relative to ViewDirRoot
public OutputSubView ( string subviewName ) : string
subviewName string
return string

OutputSubView() public method

Similiar to the OutputSubView(string) function, but with a bunch of parameters that are used just for this subview. This parameters are /not/ inheritable.
public OutputSubView ( string subviewName, IDictionary parameters ) : string
subviewName string
parameters IDictionary
return string

OutputSubView() public method

Outputs the sub view to the writer
public OutputSubView ( string subviewName, TextWriter writer, IDictionary parameters ) : void
subviewName string Name of the subview.
writer System.IO.TextWriter The writer.
parameters IDictionary The parameters.
return void

RemoveViewComponentProperties() public method

Removes the view component properties, so they will no longer be visible to the views.
public RemoveViewComponentProperties ( IDictionary propertiesToRemove ) : void
propertiesToRemove IDictionary The properties to remove.
return void

RenderComponent() public method

public RenderComponent ( string componentName ) : void
componentName string
return void

RenderComponent() public method

public RenderComponent ( string componentName, IDictionary parameters ) : void
componentName string
parameters IDictionary
return void

Run() public abstract method

Runs this instance, this is generated by the script
public abstract Run ( ) : void
return void

SetOutputStream() public method

This is required because we may want to replace the output stream and get the correct behavior from components call RenderText() or RenderSection()
public SetOutputStream ( TextWriter newOutputStream ) : IDisposable
newOutputStream System.IO.TextWriter
return IDisposable

SetParent() public method

Sets the parent.
public SetParent ( BrailBase myParent ) : void
myParent BrailBase My parent.
return void

TryGetParameter() public method

this is called by ReplaceUnknownWithParameters step to create a more dynamic experiance any uknown identifier with the prefix of ? will be translated into a call for TryGetParameter('identifier name without the ? prefix'). This method will return null if the value it not found.
public TryGetParameter ( string name ) : object
name string
return object

Property Details

__controller protected property

protected Controller,Castle.MonoRail.Framework __controller
return Castle.MonoRail.Framework.Controller

childOutput protected property

This is used by layout scripts only, for outputing the child's content
protected TextWriter,System.IO childOutput
return System.IO.TextWriter

context protected property

protected IRailsEngineContext context
return IRailsEngineContext

parent protected property

usually used by the layout to refer to its view, or a subview to its parent
protected BrailBase,Castle.MonoRail.Views.Brail parent
return BrailBase

viewEngine protected property

protected BooViewEngine,Castle.MonoRail.Views.Brail viewEngine
return BooViewEngine