@@ -141,48 +141,39 @@ static void CreateSamplePlan(string handlerCsvList, string outPath, bool verbose
141141 if ( verbose )
142142 p = Plan . CreateSample ( ) ;
143143
144- //todo: [ss] this is absolute $#!+ loop structure, need to fix
145- string [ ] handlers = handlerCsvList . Split ( ',' ) ;
144+ List < string > handlers = GetHandlerList ( handlerCsvList ) ;
146145 foreach ( string handlerType in handlers )
147146 {
148- if ( handlerType . ToLower ( ) . EndsWith ( ":all" ) )
147+ ActionItem a = new ActionItem ( )
149148 {
150- string [ ] parts = handlerType . Split ( ':' ) ;
151- CreateSamplePlanAll ( parts [ 0 ] , outPath , verbose ) ;
149+ Name = handlerType ,
150+ Description = $ "Example Action for { handlerType } ."
151+ } ;
152+ a . Handler = new HandlerInfo ( ) ;
153+ a . Actions = null ;
154+
155+ IHandlerRuntime hr = null ;
156+ try
157+ {
158+ hr = AssemblyLoader . Load ( handlerType , handlerType ) ;
159+ }
160+ catch { }
161+
162+ if ( hr != null )
163+ {
164+ a . Description = $ "Resolved Handler from [{ hr . RuntimeType } ].";
165+ a . Handler . Type = handlerType ;
166+ a . Handler . Config = new ParameterInfo ( ) ;
167+ a . Handler . Config . Values = hr . GetConfigInstance ( ) ;
168+ a . Parameters = new ParameterInfo ( ) ;
169+ a . Parameters . Values = hr . GetParametersInstance ( ) ;
152170 }
153171 else
154172 {
155- ActionItem a = new ActionItem ( )
156- {
157- Name = handlerType ,
158- Description = $ "Example Action for { handlerType } ."
159- } ;
160- a . Handler = new HandlerInfo ( ) ;
161- a . Actions = null ;
162-
163- IHandlerRuntime hr = null ;
164- try
165- {
166- hr = AssemblyLoader . Load ( handlerType , handlerType ) ;
167- }
168- catch { }
169-
170- if ( hr != null )
171- {
172- a . Description = $ "Resolved Handler from [{ hr . RuntimeType } ].";
173- a . Handler . Type = handlerType ;
174- a . Handler . Config = new ParameterInfo ( ) ;
175- a . Handler . Config . Values = hr . GetConfigInstance ( ) ;
176- a . Parameters = new ParameterInfo ( ) ;
177- a . Parameters . Values = hr . GetParametersInstance ( ) ;
178- }
179- else
180- {
181- a . Handler . Type = $ "** Error - Could not load [{ handlerType } ].";
182- }
183-
184- p . Actions . Add ( a ) ;
173+ a . Handler . Type = $ "** Error - Could not load [{ handlerType } ].";
185174 }
175+
176+ p . Actions . Add ( a ) ;
186177 }
187178
188179 if ( ! string . IsNullOrWhiteSpace ( outPath ) )
@@ -191,7 +182,26 @@ static void CreateSamplePlan(string handlerCsvList, string outPath, bool verbose
191182 Console . WriteLine ( p . ToYaml ( ) ) ;
192183 }
193184
194- static void CreateSamplePlanAll ( string handlerLib , string outPath , bool verbose = false )
185+ static List < string > GetHandlerList ( string handlerCsvList )
186+ {
187+ List < string > result = new List < string > ( ) ;
188+ string [ ] handlers = handlerCsvList . Split ( ',' ) ;
189+ foreach ( string handlerType in handlers )
190+ {
191+ if ( handlerType . ToLower ( ) . EndsWith ( ":all" ) )
192+ {
193+ string [ ] parts = handlerType . Split ( ':' ) ;
194+ DiscoverHandlers ( parts [ 0 ] , ref result ) ;
195+ }
196+ else
197+ {
198+ result . Add ( handlerType ) ;
199+ }
200+ }
201+ return result ;
202+ }
203+
204+ static void DiscoverHandlers ( string handlerLib , ref List < string > handlers )
195205 {
196206 //probe all the Types, looking for partial match in name
197207 try
@@ -201,9 +211,9 @@ static void CreateSamplePlanAll(string handlerLib, string outPath, bool verbose
201211 Type [ ] types = hrAsm . GetTypes ( ) ;
202212 foreach ( Type t in types )
203213 if ( t . GetInterfaces ( ) . Contains ( typeof ( IHandlerRuntime ) ) )
204- CreateSamplePlan ( $ "{ handlerLib } :{ t . Name } ", outPath , verbose ) ;
214+ handlers . Add ( $ "{ handlerLib } :{ t . Name } " ) ;
205215 }
206- catch ( Exception ex ) { throw ; }
216+ catch { } // throw;
207217 }
208218 #endregion
209219
0 commit comments