Skip to content

Commit c84688f

Browse files
committed
fixed junk loop
1 parent 3ee9c55 commit c84688f

3 files changed

Lines changed: 50 additions & 40 deletions

File tree

Synapse.Core/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,4 @@
3737
// by using the '*' as shown below:
3838
// [assembly: AssemblyVersion("1.0.*")]
3939
[assembly: AssemblyVersion( "0.1.0.0" )]
40-
[assembly: AssemblyFileVersion( "0.1.17142.0" )]
40+
[assembly: AssemblyFileVersion( "0.1.17143.0" )]

Synapse.cli/Program.cs

Lines changed: 48 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Synapse.cli/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
3535
[assembly: AssemblyVersion( "0.1.0.0" )]
36-
[assembly: AssemblyFileVersion( "0.1.17142.0" )]
36+
[assembly: AssemblyFileVersion( "0.1.17143.0" )]

0 commit comments

Comments
 (0)