ConvertToTrigger Pattern

Sometimes it’s necessary to convert a signal that contains a content to a contentless trigger. To follow the DRY principle (Don’t Repeat Yourself), a generic pattern is implemented. There are no parameters needed. You just have to add a new pattern based step as shown in the previous chapters of this document. The following snippet demonstrates the usage:

$Flow SampleFlow {
   $Step ConvertStringToTrigger { Pattern = "ConvertToTrigger" }
        
    $Wire SourceStep?OutputPin -> ConvertStringToTrigger
    $Wire ConvertStringToTrigger -> TargetStep?InputPin
}

Again (as usual) no implementations must be changed. The following code snippet shows the used base class for a single parameter / data type to convert:

/// <summary>Converts a signal with content to trigger without any content
/// </summary>
public abstract class ConvertToTrigger<T>
{
	/// <summary>Emit the trigger
	/// </summary>
		/// <param name="arg">The argument (unused and ignored!)</param>
	public void DefaultInputPin(T arg)
	{
		DefaultOutputPin();
	}
 
	/// <summary>Trigger output
	/// </summary>
	public event Action DefaultOutputPin;
}

Previous: ThreadAsynchronizer Pattern (Version V7)
Next: Terminator Pattern

Last edited Sep 2, 2014 at 8:05 AM by InneHo, version 5