Skip to content

Instantly share code, notes, and snippets.

@SynapseProject
Created March 21, 2017 01:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SynapseProject/b8747c156843dad7119f6135d320f7bf to your computer and use it in GitHub Desktop.
Save SynapseProject/b8747c156843dad7119f6135d320f7bf to your computer and use it in GitHub Desktop.
Synapse.Core: Example of custom Handler and consuming Plan (simple).
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; }
}
}
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