Class TokenReplace
The TokenReplace class provides the option to replace tokens formatted [object:property] or [object:property|format] or [custom:no] within a string with the appropriate current property/custom values. Example for Newsletter: 'Dear [user:Displayname],' ==> 'Dear Superuser Account,' Supported Token Sources: User, Host, Portal, Tab, Module, Membership, Profile, Row, Date, Ticks, ArrayList (Custom), IDictionary.
Inheritance
Inherited Members
Namespace: DotNetNuke.Services.Tokens
Assembly: DotNetNuke.dll
Syntax
public class TokenReplace : BaseCustomTokenReplace
Constructors
| Improve this Doc View SourceTokenReplace()
Initializes a new instance of the TokenReplace class. creates a new TokenReplace object for default context.
Declaration
public TokenReplace()
TokenReplace(Scope, Int32)
Initializes a new instance of the TokenReplace class. creates a new TokenReplace object for custom context.
Declaration
public TokenReplace(Scope accessLevel, int moduleID)
Parameters
Type | Name | Description |
---|---|---|
Scope | accessLevel | Security level granted by the calling object. |
System.Int32 | moduleID | ID of the current module. |
TokenReplace(Scope, String, PortalSettings, UserInfo, Int32)
Initializes a new instance of the TokenReplace class. creates a new TokenReplace object for custom context.
Declaration
public TokenReplace(Scope accessLevel, string language, PortalSettings portalSettings, UserInfo user, int moduleID)
Parameters
Type | Name | Description |
---|---|---|
Scope | accessLevel | Security level granted by the calling object. |
System.String | language | Locale to be used for formatting etc. |
PortalSettings | portalSettings | PortalSettings to be used. |
UserInfo | user | user, for which the properties shall be returned. |
System.Int32 | moduleID | ID of the current module. |
TokenReplace(Scope, String, PortalSettings, UserInfo)
Initializes a new instance of the TokenReplace class. creates a new TokenReplace object for custom context.
Declaration
public TokenReplace(Scope accessLevel, string language, PortalSettings portalSettings, UserInfo user)
Parameters
Type | Name | Description |
---|---|---|
Scope | accessLevel | Security level granted by the calling object. |
System.String | language | Locale to be used for formatting etc. |
PortalSettings | portalSettings | PortalSettings to be used. |
UserInfo | user | user, for which the properties shall be returned. |
TokenReplace(Scope)
Initializes a new instance of the TokenReplace class. creates a new TokenReplace object for custom context.
Declaration
public TokenReplace(Scope accessLevel)
Parameters
Type | Name | Description |
---|---|---|
Scope | accessLevel | Security level granted by the calling object. |
TokenReplace(Int32)
Initializes a new instance of the TokenReplace class. creates a new TokenReplace object for default context and the current module.
Declaration
public TokenReplace(int moduleID)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | moduleID | ID of the current module. |
Properties
| Improve this Doc View SourceModuleId
Gets or sets /sets the current ModuleID to be used for 'User:' token replacement.
Declaration
public int ModuleId { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 | ModuleID (Integer). |
ModuleInfo
Gets or sets the module settings object to use for 'Module:' token replacement.
Declaration
public ModuleInfo ModuleInfo { get; set; }
Property Value
Type | Description |
---|---|
ModuleInfo |
PortalSettings
Gets or sets /sets the portal settings object to use for 'Portal:' token replacement.
Declaration
public PortalSettings PortalSettings { get; set; }
Property Value
Type | Description |
---|---|
PortalSettings | PortalSettings oject. |
User
Gets or sets /sets the user object to use for 'User:' token replacement.
Declaration
public UserInfo User { get; set; }
Property Value
Type | Description |
---|---|
UserInfo | UserInfo oject. |
Methods
| Improve this Doc View SourceReplaceEnvironmentTokens(String, ArrayList, String, DataRow)
Replaces tokens in sourceText parameter with the property values.
Declaration
public string ReplaceEnvironmentTokens(string sourceText, ArrayList custom, string customCaption, DataRow row)
Parameters
Type | Name | Description |
---|---|---|
System.String | sourceText | String with [Object:Property] tokens. |
ArrayList | custom | NameValueList for replacing [custom:name] tokens, where 'custom' is specified in next param and name is either thekey or the index number in the string. |
System.String | customCaption | Token name to be used inside token [custom:name]. |
DataRow | row | DataRow, from which field values shall be used for replacement. |
Returns
Type | Description |
---|---|
System.String | string containing replaced values. |
ReplaceEnvironmentTokens(String, ArrayList, String)
Replaces tokens in sourceText parameter with the property values.
Declaration
public string ReplaceEnvironmentTokens(string sourceText, ArrayList custom, string customCaption)
Parameters
Type | Name | Description |
---|---|---|
System.String | sourceText | String with [Object:Property] tokens. |
ArrayList | custom | |
System.String | customCaption |
Returns
Type | Description |
---|---|
System.String | string containing replaced values. |
ReplaceEnvironmentTokens(String, DataRow)
Replaces tokens in sourceText parameter with the property values.
Declaration
public string ReplaceEnvironmentTokens(string sourceText, DataRow row)
Parameters
Type | Name | Description |
---|---|---|
System.String | sourceText | String with [Object:Property] tokens. |
DataRow | row |
Returns
Type | Description |
---|---|
System.String | string containing replaced values. |
ReplaceEnvironmentTokens(String, IDictionary, String)
Replaces tokens in sourceText parameter with the property values.
Declaration
public string ReplaceEnvironmentTokens(string sourceText, IDictionary custom, string customCaption)
Parameters
Type | Name | Description |
---|---|---|
System.String | sourceText | String with [Object:Property] tokens. |
IDictionary | custom | NameValueList for replacing [custom:name] tokens, where 'custom' is specified in next param and name is either thekey or the index number in the string. |
System.String | customCaption | Token name to be used inside token [custom:name]. |
Returns
Type | Description |
---|---|
System.String | string containing replaced values. |
ReplaceEnvironmentTokens(String, IDictionary, String[])
Replaces tokens in sourceText parameter with the property values.
Declaration
public string ReplaceEnvironmentTokens(string sourceText, IDictionary custom, string[] customCaptions)
Parameters
Type | Name | Description |
---|---|---|
System.String | sourceText | String with [Object:Property] tokens. |
IDictionary | custom | NameValueList for replacing [custom:name] tokens, where 'custom' is specified in next param and name is either thekey or the index number in the string. |
System.String[] | customCaptions | Token names to be used inside token [custom:name], where 'custom' is one of the values in the string array. |
Returns
Type | Description |
---|---|
System.String | string containing replaced values. |
ReplaceEnvironmentTokens(String)
Replaces tokens in sourceText parameter with the property values.
Declaration
public string ReplaceEnvironmentTokens(string sourceText)
Parameters
Type | Name | Description |
---|---|---|
System.String | sourceText | String with [Object:Property] tokens. |
Returns
Type | Description |
---|---|
System.String | string containing replaced values. |
ReplaceTokens(String)
Replaces tokens in sourceText parameter with the property values, skipping environment objects.
Declaration
protected override string ReplaceTokens(string sourceText)
Parameters
Type | Name | Description |
---|---|---|
System.String | sourceText | String with [Object:Property] tokens. |
Returns
Type | Description |
---|---|
System.String | string containing replaced values. |