C# Class Castle.MonoRail.Framework.Helpers.AbstractHelper

Optional base class for helpers. Extend from this class only if your helpers needs a reference to the controller which is using it or if you need to use one of the protected utility methods.
Inheritance: IContextAware, IControllerAware
Afficher le fichier Open project: nats/castle-1.0.3-mono Class Usage Examples

Méthodes publiques

Méthode Description
BuildQueryString ( IDictionary parameters ) : string

Builds a query string encoded.

Supports multi-value query strings, using any IEnumerable as a value. IDictionary dict = new Hashtable(); dict.Add("id", 5); dict.Add("selectedItem", new int[] { 2, 4, 99 }); string querystring = BuildQueryString(dict); // should result in: "id=5&selectedItem=2&selectedItem=4&selectedItem=99&"

HtmlEncode ( string content ) : string

HTML encodes a string and returns the encoded string.

JavaScriptEscape ( string content ) : string

Escapes JavaScript with Url encoding and returns the encoded string.

Converts quotes, single quotes and CR/LFs to their representation as an escape character.

JavascriptOptions ( IDictionary jsOptions ) : string

Builds a JS associative array based on the specified dictionary instance.

For example: {name: value, other: 'another'}

LineBreaksToHtml ( String content ) : String

Escapes a content replacing line breaks with html break lines.

Quote ( object content ) : string

Quotes the specified string with double quotes

Quote ( object items ) : string[]

Quotes the specified string with singdoublele quotes

SQuote ( object content ) : string

Quotes the specified string with double quotes

ScriptBlock ( string scriptContents ) : string

Generates script block. <script type=\"text/javascript\"> scriptContents </script>

SetController ( Controller controller ) : void

Sets the controller.

UrlEncode ( string content ) : string

URL encodes a string and returns the encoded string.

UrlPathEncode ( string content ) : string

URL encodes the path portion of a URL string and returns the encoded string.

Méthodes protégées

Méthode Description
ConcatQueryString ( string leftParams, string rightParams ) : string

Concat two string in a query string format (key=value&key2=value2) building a third string with the result

GetAttributes ( IDictionary attributes ) : string

Generates HTML element attributes string from attributes. key1="value1" key2

string.Empty is returned if attributes is null or empty.

If for some DictionaryEntry.Key DictionaryEntry.Value is null or string.Empty only attribute name is appended to the string.

MergeOptions ( IDictionary userOptions, IDictionary defaultOptions ) : void

Merges userOptions with defaultOptions placing results in userOptions.

All IDictionary.Values and IDictionary.Keys in defaultOptions are copied to userOptions. Entries with the same DictionaryEntry.Key in defaultOptions and userOptions are skipped.

RenderScriptBlockToSource ( string url ) : string

Renders the a script block with a src attribute pointing to the url. The url must not have an extension.

For example, suppose you invoke it like: RenderScriptBlockToSource("/my/url/to/my/scripts");

That will render ]]> As you see the file extension will be inferred

RenderScriptBlockToSource ( string url, string queryString ) : string

Renders the a script block with a src attribute pointing to the url sending the querystring as parameter. The url must not have an extension.

For example, suppose you invoke it like: RenderScriptBlockToSource("/my/url/to/my/scripts", "locale=pt-br");

That will render ]]> As you see the file extension will be inferred

Method Details

BuildQueryString() public méthode

Builds a query string encoded.
Supports multi-value query strings, using any IEnumerable as a value. IDictionary dict = new Hashtable(); dict.Add("id", 5); dict.Add("selectedItem", new int[] { 2, 4, 99 }); string querystring = BuildQueryString(dict); // should result in: "id=5&selectedItem=2&selectedItem=4&selectedItem=99&"
public BuildQueryString ( IDictionary parameters ) : string
parameters IDictionary The parameters
Résultat string

ConcatQueryString() protected méthode

Concat two string in a query string format (key=value&key2=value2) building a third string with the result
protected ConcatQueryString ( string leftParams, string rightParams ) : string
leftParams string key values
rightParams string key values
Résultat string

GetAttributes() protected méthode

Generates HTML element attributes string from attributes. key1="value1" key2
string.Empty is returned if attributes is null or empty.

If for some DictionaryEntry.Key DictionaryEntry.Value is null or string.Empty only attribute name is appended to the string.

protected GetAttributes ( IDictionary attributes ) : string
attributes IDictionary The attributes for the element.
Résultat string

HtmlEncode() public méthode

HTML encodes a string and returns the encoded string.
public HtmlEncode ( string content ) : string
content string The text string to HTML encode.
Résultat string

JavaScriptEscape() public méthode

Escapes JavaScript with Url encoding and returns the encoded string.
Converts quotes, single quotes and CR/LFs to their representation as an escape character.
public JavaScriptEscape ( string content ) : string
content string The text to URL encode and escape JavaScript within.
Résultat string

JavascriptOptions() public static méthode

Builds a JS associative array based on the specified dictionary instance.

For example: {name: value, other: 'another'}

public static JavascriptOptions ( IDictionary jsOptions ) : string
jsOptions IDictionary The js options.
Résultat string

LineBreaksToHtml() public méthode

Escapes a content replacing line breaks with html break lines.
public LineBreaksToHtml ( String content ) : String
content String The text to escape.
Résultat String

MergeOptions() protected méthode

Merges userOptions with defaultOptions placing results in userOptions.
All IDictionary.Values and IDictionary.Keys in defaultOptions are copied to userOptions. Entries with the same DictionaryEntry.Key in defaultOptions and userOptions are skipped.
protected MergeOptions ( IDictionary userOptions, IDictionary defaultOptions ) : void
userOptions IDictionary The user options.
defaultOptions IDictionary The default options.
Résultat void

Quote() public static méthode

Quotes the specified string with double quotes
public static Quote ( object content ) : string
content object The content.
Résultat string

Quote() public static méthode

Quotes the specified string with singdoublele quotes
public static Quote ( object items ) : string[]
items object Items to quote
Résultat string[]

RenderScriptBlockToSource() protected méthode

Renders the a script block with a src attribute pointing to the url. The url must not have an extension.

For example, suppose you invoke it like: RenderScriptBlockToSource("/my/url/to/my/scripts");

That will render ]]> As you see the file extension will be inferred

protected RenderScriptBlockToSource ( string url ) : string
url string The url for the scripts (should start with a '/')
Résultat string

RenderScriptBlockToSource() protected méthode

Renders the a script block with a src attribute pointing to the url sending the querystring as parameter. The url must not have an extension.

For example, suppose you invoke it like: RenderScriptBlockToSource("/my/url/to/my/scripts", "locale=pt-br");

That will render ]]> As you see the file extension will be inferred

protected RenderScriptBlockToSource ( string url, string queryString ) : string
url string The url for the scripts (should start with a '/')
queryString string The query string.
Résultat string

SQuote() public static méthode

Quotes the specified string with double quotes
public static SQuote ( object content ) : string
content object The content.
Résultat string

ScriptBlock() public static méthode

Generates script block. <script type=\"text/javascript\"> scriptContents </script>
public static ScriptBlock ( string scriptContents ) : string
scriptContents string The script contents.
Résultat string

SetController() public méthode

Sets the controller.
public SetController ( Controller controller ) : void
controller Controller Current view's .
Résultat void

UrlEncode() public méthode

URL encodes a string and returns the encoded string.
public UrlEncode ( string content ) : string
content string The text to URL encode.
Résultat string

UrlPathEncode() public méthode

URL encodes the path portion of a URL string and returns the encoded string.
public UrlPathEncode ( string content ) : string
content string The text to URL encode.
Résultat string