Let's take a quick look at how the WikiTalk Substring method is implemented for extracting part of a string:
[ExposedMethod(ExposedMethodFlags.CachePolicyNone, "Answer a substring of this string ...")]
public string Substring(ExecutionContext ctx, int index, [ExposedParameter(true)] int length)
{
if (ctx.TopFrame.WasParameterSupplied(2))
return Value.Substring(index, length);
else
return Value.Substring(index);
}
This is an example of a method that requires an ExecutionContext. After this parameter, the rest of the parameters are visible in WikiTalk. In this case, there are two parameters in WikiTalk for Substring: index and length.
By default in WikiTalk, all parameters are required. In this case, though, the parameter length parameter is marked as optional with [ExposedParameter(true)].
In the implementation of this method, the code checks to see if the parameter was supplied:
if (ctx.TopFrame.WasParameterSupplied(2))
From then on, the code can do whatever it thinks is reasonable if the parameter is not supplied...