Creating a Library |
[This is preliminary documentation and is subject to change.]
Creating a Library starts with creating a class that inherits from AbstractBaseLibrary
1public class TestLibrary : AbstractBaseLibrary{ 2 3}
In the constructor of this TestLibrary would be where the TriggerHandlers are added. This happens through the Add method. Add takes a minimum of 3parameters, the Trigger you want to handle and the TriggerHandler followed by a optional description of the trigger. Hint: Its good practice to add a comment with a description of the trigger for easier debugging purposes. Monkeyspeak also goes a step further by giving you informative Exceptions when a exception is raised by a Trigger by giving you the Library class followed by the TriggerHandler method name and the Trigger identifier, always (#:#).
1 /// <summary> 2/// Test Library Example 3 /// </summary> 4 public class TestLibrary : AbstractBaseLibrary{ 5 6 /// <summary> 7 /// Add triggers through the constructor 8 /// </summary> 9 public TestLibrary(){ 10 // (0:0) when someone does something, 11 Add(TriggerType.Cause, 0, WhenSomeoneDoesSomething, 12 "(0:0) when someone does something,"); 13 } 14 15 /// <summary> 16/// (0:0) when someone does something, 17 /// </summary> 18 private bool WhenSomeoneDoesSomething(TriggerReader reader){ 19 return EventManager.SomeoneDidSomething(); 20 } 21 }
Now the TestLibrary is complete. We have our TriggerHandler WhenSomeoneDoesSomething registered to TriggerType.Cause, 0 or Trigger (0:0) when someone does something, Now when you call GettingStarted it will look for the trigger (0:0) and call our handler WhenSomeoneDoesSomething.