HomePage HomePage
JW Davidson JW Davidson

RSS feed for the TestJwd namespace

Show Changes Show Changes
Edit Edit
Print Print
Recent Changes Recent Changes
Subscriptions Subscriptions
Lost and Found Lost and Found
Find References Find References
Local Search

History

9/19/2007 2:25:12 PM
-74.15.253.157
List all versions List all versions
Optional Wiki Talk Parameters
.
Summary
WikiTalk methods can support optional parameters. Here are some notes on implementing such methods.

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...

Not logged in. Log in

The wiki for all things Objective Design Solutions

Recent Topics
OptionalWikiTalkP... OptionalWikiTalkP...
List all versions List all versions
Go to Google.com
Change Style
Powered by Flexwiki v2.0.0.218