@@ -141,46 +141,70 @@ 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
144145 string [ ] handlers = handlerCsvList . Split ( ',' ) ;
145146 foreach ( string handlerType in handlers )
146147 {
147- ActionItem a = new ActionItem ( )
148+ if ( handlerType . ToLower ( ) . EndsWith ( ":all" ) )
148149 {
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 ( ) ;
150+ string [ ] parts = handlerType . Split ( ':' ) ;
151+ CreateSamplePlanAll ( parts [ 0 ] , outPath , verbose ) ;
170152 }
171153 else
172154 {
173- a . Handler . Type = $ "** Error - Could not load [{ handlerType } ].";
174- }
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+ }
175183
176- p . Actions . Add ( a ) ;
184+ p . Actions . Add ( a ) ;
185+ }
177186 }
178187
179188 if ( ! string . IsNullOrWhiteSpace ( outPath ) )
180189 File . WriteAllText ( outPath , p . ToYaml ( ) ) ;
181190 else
182191 Console . WriteLine ( p . ToYaml ( ) ) ;
183192 }
193+
194+ static void CreateSamplePlanAll ( string handlerLib , string outPath , bool verbose = false )
195+ {
196+ //probe all the Types, looking for partial match in name
197+ try
198+ {
199+ System . Reflection . Assembly hrAsm = System . Reflection . Assembly . Load ( handlerLib ) ;
200+
201+ Type [ ] types = hrAsm . GetTypes ( ) ;
202+ foreach ( Type t in types )
203+ if ( t . GetInterfaces ( ) . Contains ( typeof ( IHandlerRuntime ) ) )
204+ CreateSamplePlan ( $ "{ handlerLib } :{ t . Name } ", outPath , verbose ) ;
205+ }
206+ catch ( Exception ex ) { throw ; }
207+ }
184208 #endregion
185209
186210
@@ -240,10 +264,11 @@ static void WriteHelpAndExit(string errorMessage = null)
240264 Console . WriteLine ( " decrypt{0,5} - filePath: Valid path to plan file to decrypt." , "" ) ;
241265 Console . WriteLine ( " out{0,9} - filePath: Optional output filePath." , "" ) ;
242266 Console . WriteLine ( " {0,10}If [out] not specified, will encrypt/decrypt in-place.\r \n " , "" ) ;
243- Console_WriteLine ( " synapse.cli.exe sample:{0}handlerLib:handlerName,...{1} [out:{0}filePath{1}]" , ConsoleColor . Cyan , "{" , "}" ) ;
267+ Console_WriteLine ( " synapse.cli.exe sample:{0}handlerLib:{0}all| handlerName{1} ,...{1} [out:{0}filePath{1}]" , ConsoleColor . Cyan , "{" , "}" ) ;
244268 Console . WriteLine ( " [verbose:true|false]" , "{" , "}" ) ;
245269 Console_WriteLine ( "\r \n - Create a sample Plan with the specified Handler(s).\r \n " , ConsoleColor . Green , "" ) ;
246270 Console . WriteLine ( " sample{0,5} - A csv list of handlerLib:handlerName pairs." , "" ) ;
271+ Console . WriteLine ( " {0,10}Use handlerLib:all to discover all Handlers in a lib." , "" ) ;
247272 Console . WriteLine ( " out{0,9} - filePath: Optional output filePath." , "" ) ;
248273 Console . WriteLine ( " {0,10}If [out] not specified, will output to screen." , "" ) ;
249274 Console . WriteLine ( " verbose{0,5} - If true, adds example values for all Plan options." , "" ) ;
0 commit comments