Created
March 21, 2017 01:05
-
-
Save SynapseProject/b8747c156843dad7119f6135d320f7bf to your computer and use it in GitHub Desktop.
Synapse.Core: Example of custom Handler and consuming Plan (simple).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using Synapse.Core; | |
namespace ExampleHandler | |
{ | |
//Inherit HandlerRuntimeBase for the easiest implementation. | |
public class MyHandler : HandlerRuntimeBase | |
{ | |
override public ExecuteResult Execute(HandlerStartInfo startInfo) | |
{ | |
MyHandlerParameters parms = DeserializeOrNew<MyHandlerParameters>( startInfo.Parameters ); | |
string returnData = null; | |
if( parms.Query == "What's going to happen?" ) | |
returnData = "Something wonderful." | |
OnLogMessage( "Execute", "A lot has happened while you have been asleep." ); | |
OnProgress( "Execute", "Don't worry, I'm just observing.", StatusType.Complete, startInfo.InstanceId, Int32.MaxValue ); | |
return new ExecuteResult() { Status = StatusType.Complete, ExitData = returnData }; | |
} | |
} | |
public class MyHandlerParameters | |
{ | |
public string Query { get; set; } | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Name: MyHandler_Sample_Plan | |
Description: Shows a consuming Plan for a custom Handler. | |
Actions: | |
- Name: Sample_Action | |
Handler: | |
Type: ExampleHandler:MyHandler | |
Parameters: | |
Type: Yaml | |
Values: | |
Query: Who's calling? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment