C# Class Rock.ExtensionMethods

Rock Lava related extensions
Mostra file Open project: SparkDevNetwork/Rock

Public Methods

Method Description
Age ( this start ) : int

Returns the age at the current date.

EndOfWeek ( this dt, DayOfWeek startOfWeek ) : System.DateTime

Returns the date of the last day of the week for the specified date/time For example, if Monday is considered the start of the week: "2015-05-13" would return "2015-05-17" from http://stackoverflow.com/a/38064/1755417

GetColumnByHeaderText ( this dataControlFieldCollection, string headerText ) : DataControlField

Gets the grid column that matches the header text.

HasMergeFields ( this content ) : bool

Determines whether the string potentially has merge fields in it. NOTE: Might return true even though it doesn't really have merge fields, but something like looks like it. For example '{56408602-5E41-4D66-98C7-BD361CD93AED}'

ResolveClientIds ( this content, string clientId ) : string

Resolve any client ids in the string. This is used with Lava when writing out postback commands.

ResolveMergeFields ( this content, object>.IDictionary mergeObjects, Person currentPersonOverride ) : string

Use DotLiquid to resolve any merge codes within the content using the values in the mergeObjects.

ResolveMergeFields ( this content, object>.IDictionary mergeObjects, Person currentPersonOverride, string enabledLavaCommands ) : string

Resolves the merge fields.

ResolveMergeFields ( this content, object>.IDictionary mergeObjects, bool encodeStrings = false, bool throwExceptionOnErrors = false ) : string

Use DotLiquid to resolve any merge codes within the content using the values in the mergeObjects.

ResolveMergeFields ( this content, object>.IDictionary mergeObjects, string enabledLavaCommands, bool encodeStrings = false, bool throwExceptionOnErrors = false ) : string

Resolves the merge fields.

StartOfWeek ( this dt, DayOfWeek startOfWeek ) : System.DateTime

Returns the date of the start of the week for the specified date/time For example, if Monday is considered the start of the week: "2015-05-13" would return "2015-05-11" from http://stackoverflow.com/a/38064/1755417

SundayDate ( this dt, DayOfWeek startOfWeek = DayOfWeek.Monday ) : System.DateTime

Sundays the date.

ToElapsedString ( this dateTime, bool condensed = false, bool includeTime = true ) : string

Returns a friendly elapsed time string.

ToJavascriptMilliseconds ( this dateTime ) : long

Converts the date to an Epoch of milliseconds since 1970/1/1.

ToMonthDayString ( this dateTime ) : string

Converts the date to a string containing month and day values ( culture-specific ).

ToRelativeDateString ( this dateTime, int maxDays = null ) : string

Returns a string in FB style relative format (x seconds ago, x minutes ago, about an hour ago, etc.). or if max days has already passed in FB datetime format (February 13 at 11:28am or November 5, 2011 at 1:57pm).

ToTimeString ( this timespan ) : string

Returns a TimeSpan as h:mm AM/PM (culture invariant) Examples: 1:45 PM, 12:01 AM

TotalMonths ( this end, System.DateTime start ) : int

The total months.

TotalYears ( this end, System.DateTime start ) : int

The total years.

Update ( object>.this dictionary, string key, object value ) : void

Adds a new key/value to dictionary or if key already exists will update existing value.

lavaDebugInfo ( this lavaObject, RockContext rockContext = null, string preText = "", string postText = "" ) : string

Returns an html representation of object that is available to lava.

Private Methods

Method Description
EncodeStringTransformer ( object s ) : object

Html Encodes string values that are processed by a lava filter

LiquidizeChildren ( this myObject, int levelsDeep, RockContext rockContext = null, Dictionary entityHistory = null, string parentElement = "" ) : object

Liquidizes the child properties of an object for displaying debug information about fields available for lava templates

formatLavaDebugInfo ( object liquidizedObject, int levelsDeep, string parents = "" ) : string

Method Details

Age() public static method

Returns the age at the current date.
public static Age ( this start ) : int
start this
return int

EndOfWeek() public static method

Returns the date of the last day of the week for the specified date/time For example, if Monday is considered the start of the week: "2015-05-13" would return "2015-05-17" from http://stackoverflow.com/a/38064/1755417
public static EndOfWeek ( this dt, DayOfWeek startOfWeek ) : System.DateTime
dt this The dt.
startOfWeek DayOfWeek The start of week.
return System.DateTime

GetColumnByHeaderText() public static method

Gets the grid column that matches the header text.
public static GetColumnByHeaderText ( this dataControlFieldCollection, string headerText ) : DataControlField
dataControlFieldCollection this The data control field collection.
headerText string The header text.
return DataControlField

HasMergeFields() public static method

Determines whether the string potentially has merge fields in it. NOTE: Might return true even though it doesn't really have merge fields, but something like looks like it. For example '{56408602-5E41-4D66-98C7-BD361CD93AED}'
public static HasMergeFields ( this content ) : bool
content this The content.
return bool

ResolveClientIds() public static method

Resolve any client ids in the string. This is used with Lava when writing out postback commands.
public static ResolveClientIds ( this content, string clientId ) : string
content this The content.
clientId string The client identifier.
return string

ResolveMergeFields() public static method

Use DotLiquid to resolve any merge codes within the content using the values in the mergeObjects.
public static ResolveMergeFields ( this content, object>.IDictionary mergeObjects, Person currentPersonOverride ) : string
content this The content.
mergeObjects object>.IDictionary The merge objects.
currentPersonOverride Person The current person override.
return string

ResolveMergeFields() public static method

Resolves the merge fields.
public static ResolveMergeFields ( this content, object>.IDictionary mergeObjects, Person currentPersonOverride, string enabledLavaCommands ) : string
content this The content.
mergeObjects object>.IDictionary The merge objects.
currentPersonOverride Person The current person override.
enabledLavaCommands string The enabled lava commands.
return string

ResolveMergeFields() public static method

Use DotLiquid to resolve any merge codes within the content using the values in the mergeObjects.
public static ResolveMergeFields ( this content, object>.IDictionary mergeObjects, bool encodeStrings = false, bool throwExceptionOnErrors = false ) : string
content this The content.
mergeObjects object>.IDictionary The merge objects.
encodeStrings bool if set to true, string values will be XML Encoded. For example, if you are creating an XML doc (not HTML), you probably want to set this to true.
throwExceptionOnErrors bool if set to true [throw exception on errors].
return string

ResolveMergeFields() public static method

Resolves the merge fields.
public static ResolveMergeFields ( this content, object>.IDictionary mergeObjects, string enabledLavaCommands, bool encodeStrings = false, bool throwExceptionOnErrors = false ) : string
content this The content.
mergeObjects object>.IDictionary The merge objects.
enabledLavaCommands string The enabled lava commands.
encodeStrings bool if set to true [encode strings].
throwExceptionOnErrors bool if set to true [throw exception on errors].
return string

StartOfWeek() public static method

Returns the date of the start of the week for the specified date/time For example, if Monday is considered the start of the week: "2015-05-13" would return "2015-05-11" from http://stackoverflow.com/a/38064/1755417
public static StartOfWeek ( this dt, DayOfWeek startOfWeek ) : System.DateTime
dt this The dt.
startOfWeek DayOfWeek The start of week.
return System.DateTime

SundayDate() public static method

Sundays the date.
public static SundayDate ( this dt, DayOfWeek startOfWeek = DayOfWeek.Monday ) : System.DateTime
dt this The date to check.
startOfWeek DayOfWeek The start of week.
return System.DateTime

ToElapsedString() public static method

Returns a friendly elapsed time string.
public static ToElapsedString ( this dateTime, bool condensed = false, bool includeTime = true ) : string
dateTime this The date time.
condensed bool if set to true [condensed].
includeTime bool if set to true [include time].
return string

ToJavascriptMilliseconds() public static method

Converts the date to an Epoch of milliseconds since 1970/1/1.
public static ToJavascriptMilliseconds ( this dateTime ) : long
dateTime this The date time.
return long

ToMonthDayString() public static method

Converts the date to a string containing month and day values ( culture-specific ).
public static ToMonthDayString ( this dateTime ) : string
dateTime this The date time.
return string

ToRelativeDateString() public static method

Returns a string in FB style relative format (x seconds ago, x minutes ago, about an hour ago, etc.). or if max days has already passed in FB datetime format (February 13 at 11:28am or November 5, 2011 at 1:57pm).
public static ToRelativeDateString ( this dateTime, int maxDays = null ) : string
dateTime this the datetime to convert to relative time.
maxDays int maximum number of days before formatting in FB date-time format (ex. November 5, 2011 at 1:57pm)
return string

ToTimeString() public static method

Returns a TimeSpan as h:mm AM/PM (culture invariant) Examples: 1:45 PM, 12:01 AM
public static ToTimeString ( this timespan ) : string
timespan this The timespan.
return string

TotalMonths() public static method

The total months.
public static TotalMonths ( this end, System.DateTime start ) : int
end this The end.
start System.DateTime The start.
return int

TotalYears() public static method

The total years.
public static TotalYears ( this end, System.DateTime start ) : int
end this The end.
start System.DateTime The start.
return int

Update() public static method

Adds a new key/value to dictionary or if key already exists will update existing value.
public static Update ( object>.this dictionary, string key, object value ) : void
dictionary object>.this The dictionary.
key string The key.
value object The value.
return void

lavaDebugInfo() public static method

Returns an html representation of object that is available to lava.
public static lavaDebugInfo ( this lavaObject, RockContext rockContext = null, string preText = "", string postText = "" ) : string
lavaObject this The liquid object.
rockContext RockContext The rock context.
preText string The pre text.
postText string The post text.
return string