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) 

파일 보기 프로젝트 열기: nats/castle-1.0.3-mono 1 사용 예제들

공개 메소드들

메소드 설명
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