@@ -15,6 +15,8 @@ namespace JDunkerley.AlteryxAddIns.Framework
1515 public abstract class BaseEngine < TConfig > : AlteryxRecordInfoNet . INetPlugin , IBaseEngine
1616 where TConfig : new ( )
1717 {
18+ private readonly IOutputHelperFactory _outputHelperFactory ;
19+
1820 private readonly Dictionary < string , PropertyInfo > _inputs ;
1921 private readonly Dictionary < string , PropertyInfo > _outputs ;
2022
@@ -26,13 +28,20 @@ public abstract class BaseEngine<TConfig> : AlteryxRecordInfoNet.INetPlugin, IBa
2628 /// Initializes a new instance of the <see cref="BaseEngine{T}"/> class.
2729 /// </summary>
2830 /// <param name="recordCopierFactory">Factory to create copiers</param>
29- protected BaseEngine ( IRecordCopierFactory recordCopierFactory )
31+ /// <param name="outputHelperFactory">Factory to create output helpers</param>
32+ protected BaseEngine ( IRecordCopierFactory recordCopierFactory , IOutputHelperFactory outputHelperFactory )
3033 {
3134 this . RecordCopierFactory = recordCopierFactory ;
35+ this . _outputHelperFactory = outputHelperFactory ;
3236
3337 var type = this . GetType ( ) ;
3438 this . _inputs = type . GetProperties < AlteryxRecordInfoNet . IIncomingConnectionInterface > ( ) ;
35- this . _outputs = type . GetProperties < OutputHelper > ( ) ;
39+ this . _outputs = type . GetProperties < IOutputHelper > ( ) ;
40+
41+ if ( this . _outputHelperFactory == null && this . _outputs . Count > 0 )
42+ {
43+ throw new ArgumentNullException ( nameof ( outputHelperFactory ) , "Tool has an output but no factory has been provided." ) ;
44+ }
3645 }
3746
3847 /// <summary>
@@ -88,7 +97,7 @@ public void PI_Init(int nToolId, AlteryxRecordInfoNet.EngineInterface engineInte
8897
8998 foreach ( var kvp in this . _outputs )
9099 {
91- kvp . Value . SetValue ( this , new OutputHelper ( this , kvp . Key ) , null ) ;
100+ kvp . Value . SetValue ( this , this . _outputHelperFactory . CreateOutputHelper ( this , kvp . Key ) , null ) ;
92101 }
93102
94103 this . OnInitCalled ( ) ;
0 commit comments