Call Tokens
Call tokens were added in the standard DNNStuff.Utilities.dll which most DNNStuff modules now support. The #CALL token was added so you could reflectively call a function from another assembly (dll) to generate a replacement value based on data available in the current context.
Syntax
[#CALL ASSEMBLY="assemblyname" CLASS="classname" METHOD="methodname" VALUES="comma separated values"]
Example 1
[#CALL ASSEMBLY="MyFunctions" CLASS="Addition" METHOD="AddNumbers" VALUES="1,2"]
This will load MyFunctions.dll (from the bin folder), create an instance for the Addition class, and invoke the AddNumbers function passing 1 and 2 as parameters.
Example 2
[#CALL ASSEMBLY="MyFunctions" CLASS="Class1" METHOD="AppendThreeParameters" VALUES="1,2,3"]
This will load MyFunctions.dll (from the bin folder), create an instance for the Class1 class, and invoke the AppendThreeParameters function passing 1,2 and 3 as parameters and will result in the replacement value of 1-2-3
Sample Code for Example 2
Compile this simple class into the MyFunctions.dll assembly, place it in your DotNetNuke bin folder, and then use the above [#CALL] token syntax in Example 2 to try it out.
MyFunctions.dll
using System;
namespace MyFunctions
{
public class Class1
{
public string AppendThreeParameters(string s1, string s2, string s3)
{
return s1 + "-" + s2 + "-" + s3;
}
}
}
Where this really comes in handy of course, is passing in dynamic parameters from report rows or other dynamic data. In examples 1 and 2 we were passing in know values and getting back what we expected, not very exciting at all. Now, look at the following example.
Example 3
[#CALL ASSEMBLY="MyCompany.Utilities" CLASS="UrlUtils" METHOD="EncodeUrl" VALUES="[UrlFromDatabase]"]
Just imagine now that we have a query in SQLView Pro that returns a column named UrlFromDatabase. This example will pass the value contained in the [UrlFromDatabase] datarow column into the values parameter of the #CALL and return the result.