C# Класс NVelocity.App.Tools.VelocityFormatter

Formatting tool for inserting into the Velocity WebContext. Can format dates or lists of objects.

Here's an example of some uses:

 $formatter.formatShortDate($object.Date) $formatter.formatLongDate($db.getRecord(232).getDate()) $formatter.formatArray($array) $formatter.limitLen(30, $object.Description) 

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

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

Метод Описание
FormatArray ( Object array ) : String

Formats an array into the form "A, B and C".

FormatArray ( Object array, String delim ) : String

Formats an array into the form "A<delim>B<delim>C".

FormatArray ( Object array, String delim, String finaldelim ) : String

Formats an array into the form "A<delim>B<finaldelim>C".

FormatLongDate ( System.DateTime date ) : String

Formats a date in 'long' style.

FormatLongDateTime ( System.DateTime date ) : String

Formats a date/time in 'long' style.

FormatShortDate ( System.DateTime date ) : String

Formats a date in 'short' style.

FormatShortDateTime ( System.DateTime date ) : String

Formats a date/time in 'short' style.

FormatVector ( IList list ) : String

Formats a list into the form "A, B and C".

FormatVector ( IList list, String delim ) : String

Formats a list into the form "A<delim>B<delim>C".

FormatVector ( IList list, String delim, String finaldelim ) : String

Formats a list into the form "Adelim>B<finaldelim>C".

IsNull ( Object o, Object dflt ) : Object

Returns a default value if the object passed is null.

LimitLen ( int maxlen, String value ) : String

Limits 'string' to 'maxlen' characters. If the string gets curtailed, "..." is appended to it.

LimitLen ( int maxlen, String value, String suffix ) : String

Limits 'string' to 'maxlen' character. If the string gets curtailed, 'suffix' is appended to it.

MakeAlternator ( String name, String alt1, String alt2 ) : String

Makes an alternator object that alternates between two values.

Example usage in a Velocity template: <table> $formatter.makeAlternator("rowcolor", "#c0c0c0", "#e0e0e0") #foreach $item in $items <tr><td bgcolor="$rowcolor">$item.Name</td></tr> $rowcolor.alternate() #end </table>

MakeAlternator ( String name, String alt1, String alt2, String alt3 ) : String

Makes an alternator object that alternates between three values.

MakeAlternator ( String name, String alt1, String alt2, String alt3, String alt4 ) : String

Makes an alternator object that alternates between four values.

MakeAutoAlternator ( String name, String alt1, String alt2 ) : String

Makes an alternator object that alternates between two values automatically.

VelocityFormatter ( IContext context ) : System

Constructor needs a backpointer to the context.

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

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

Formats an array into the form "A, B and C".
public FormatArray ( Object array ) : String
array Object An Object.
Результат String

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

Formats an array into the form "A<delim>B<delim>C".
public FormatArray ( Object array, String delim ) : String
array Object An Object.
delim String A String.
Результат String

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

Formats an array into the form "A<delim>B<finaldelim>C".
public FormatArray ( Object array, String delim, String finaldelim ) : String
array Object An Object.
delim String A String.
finaldelim String A String.
Результат String

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

Formats a date in 'long' style.
public FormatLongDate ( System.DateTime date ) : String
date System.DateTime A Date.
Результат String

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

Formats a date/time in 'long' style.
public FormatLongDateTime ( System.DateTime date ) : String
date System.DateTime A Date.
Результат String

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

Formats a date in 'short' style.
public FormatShortDate ( System.DateTime date ) : String
date System.DateTime A Date.
Результат String

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

Formats a date/time in 'short' style.
public FormatShortDateTime ( System.DateTime date ) : String
date System.DateTime A Date.
Результат String

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

Formats a list into the form "A, B and C".
public FormatVector ( IList list ) : String
list IList A list.
Результат String

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

Formats a list into the form "A<delim>B<delim>C".
public FormatVector ( IList list, String delim ) : String
list IList A list.
delim String A String.
Результат String

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

Formats a list into the form "Adelim>B<finaldelim>C".
public FormatVector ( IList list, String delim, String finaldelim ) : String
list IList A list.
delim String A String.
finaldelim String A String.
Результат String

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

Returns a default value if the object passed is null.
public IsNull ( Object o, Object dflt ) : Object
o Object
dflt Object
Результат Object

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

Limits 'string' to 'maxlen' characters. If the string gets curtailed, "..." is appended to it.
public LimitLen ( int maxlen, String value ) : String
maxlen int An int with the maximum length.
value String A String.
Результат String

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

Limits 'string' to 'maxlen' character. If the string gets curtailed, 'suffix' is appended to it.
public LimitLen ( int maxlen, String value, String suffix ) : String
maxlen int An int with the maximum length.
value String A String.
suffix String A String.
Результат String

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

Makes an alternator object that alternates between two values.

Example usage in a Velocity template: <table> $formatter.makeAlternator("rowcolor", "#c0c0c0", "#e0e0e0") #foreach $item in $items <tr><td bgcolor="$rowcolor">$item.Name</td></tr> $rowcolor.alternate() #end </table>

public MakeAlternator ( String name, String alt1, String alt2 ) : String
name String The name for the alternator int the context.
alt1 String The first alternate.
alt2 String The second alternate.
Результат String

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

Makes an alternator object that alternates between three values.
public MakeAlternator ( String name, String alt1, String alt2, String alt3 ) : String
name String
alt1 String
alt2 String
alt3 String
Результат String

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

Makes an alternator object that alternates between four values.
public MakeAlternator ( String name, String alt1, String alt2, String alt3, String alt4 ) : String
name String
alt1 String
alt2 String
alt3 String
alt4 String
Результат String

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

Makes an alternator object that alternates between two values automatically.
public MakeAutoAlternator ( String name, String alt1, String alt2 ) : String
name String
alt1 String
alt2 String
Результат String

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

Constructor needs a backpointer to the context.
public VelocityFormatter ( IContext context ) : System
context IContext A Context.
Результат System