8,290
edits
No edit summary |
(Update to include [HasWishCommand]) |
||
Line 3: | Line 3: | ||
Creating your own wishes requires 2.0.200.24 or greater. | Creating your own wishes requires 2.0.200.24 or greater. | ||
To create a wish, you define a <code> | To create a wish, you define a <code>WishCommand</code> attribute on a public method. This method should either be void or bool. The enclosing class must also have the <code>HasWishCommand</code> attribute | ||
<syntaxhighlight lang="csharp"> | <syntaxhighlight lang="csharp"> | ||
using XRL.Wish; | |||
[HasWishCommand] | |||
public class MyWishHandler | public class MyWishHandler | ||
{ | { | ||
// Handles "testwish:foo" or "testwish foo" as a wish command | // Handles "testwish:foo" or "testwish foo" as a wish command | ||
[ | [WishCommand(Command = "testwish")] | ||
public static bool TestWishHandler(string rest) | public static bool TestWishHandler(string rest) | ||
{ | { | ||
Line 19: | Line 21: | ||
// Handles "testwish" with nothing else! (no string param) | // Handles "testwish" with nothing else! (no string param) | ||
[ | [WishCommand(Command = "testwish")] | ||
public static void TestWishHandler() | public static void TestWishHandler() | ||
{ | { | ||
Line 30: | Line 32: | ||
// no command -- uses the method name by default! | // no command -- uses the method name by default! | ||
[ | [WishCommand] | ||
public void inc() | public void inc() | ||
{ | { | ||
Line 36: | Line 38: | ||
} | } | ||
[ | [WishCommand] | ||
public void dec() | public void dec() | ||
{ | { | ||
Line 42: | Line 44: | ||
} | } | ||
[ | [WishCommand(Regex = @"other fancy match \d things"] | ||
public void Handle(System.Text.RegularExpression.Match match) | public void Handle(System.Text.RegularExpression.Match match) | ||
{ | { |