@@ -190,7 +190,7 @@ public object Settings
190190 private bool stopProcessing ;
191191
192192 /// <summary>
193- /// Resolve DSC resoure dependency
193+ /// Resolve DSC resource dependency
194194 /// </summary>
195195 [ Parameter ( Mandatory = false ) ]
196196 public SwitchParameter ResolveDscResourceDependency
@@ -257,6 +257,21 @@ protected override void ProcessRecord()
257257 }
258258 }
259259
260+ protected override void EndProcessing ( )
261+ {
262+ ScriptAnalyzer . Instance . CleanUp ( ) ;
263+ base . EndProcessing ( ) ;
264+ }
265+
266+ protected override void StopProcessing ( )
267+ {
268+ ScriptAnalyzer . Instance . CleanUp ( ) ;
269+ base . StopProcessing ( ) ;
270+ }
271+
272+ #endregion
273+
274+ #region Methods
260275 private void ProcessInput ( )
261276 {
262277 IEnumerable < DiagnosticRecord > diagnosticsList = Enumerable . Empty < DiagnosticRecord > ( ) ;
@@ -269,61 +284,26 @@ private void ProcessInput()
269284 diagnosticsList = ScriptAnalyzer . Instance . AnalyzePath (
270285 this . SessionState . Path . GetUnresolvedProviderPathFromPSPath ( p . Path ) ,
271286 this . recurse ) ;
287+ WriteToOutput ( diagnosticsList ) ;
272288 }
273289 }
274290 else if ( String . Equals ( this . ParameterSetName , "ScriptDefinition" , StringComparison . OrdinalIgnoreCase ) )
275291 {
276292 diagnosticsList = ScriptAnalyzer . Instance . AnalyzeScriptDefinition ( scriptDefinition ) ;
293+ WriteToOutput ( diagnosticsList ) ;
277294 }
295+ }
278296
297+ private void WriteToOutput ( IEnumerable < DiagnosticRecord > diagnosticRecords )
298+ {
279299 foreach ( ILogger logger in ScriptAnalyzer . Instance . Loggers )
280300 {
281- foreach ( DiagnosticRecord diagnostic in diagnosticsList )
301+ foreach ( DiagnosticRecord diagnostic in diagnosticRecords )
282302 {
283303 logger . LogObject ( diagnostic , this ) ;
284304 }
285305 }
286306 }
287-
288- protected override void EndProcessing ( )
289- {
290- ScriptAnalyzer . Instance . CleanUp ( ) ;
291- base . EndProcessing ( ) ;
292- }
293-
294- protected override void StopProcessing ( )
295- {
296- ScriptAnalyzer . Instance . CleanUp ( ) ;
297- base . StopProcessing ( ) ;
298- }
299-
300- #endregion
301-
302- #region Methods
303-
304- //private void ProcessPathOrScriptDefinition(string pathOrScriptDefinition)
305- //{
306- // IEnumerable<DiagnosticRecord> diagnosticsList = Enumerable.Empty<DiagnosticRecord>();
307-
308- // if (String.Equals(this.ParameterSetName, "File", StringComparison.OrdinalIgnoreCase))
309- // {
310- // diagnosticsList = ScriptAnalyzer.Instance.AnalyzePath(pathOrScriptDefinition, this.recurse);
311- // }
312- // else if (String.Equals(this.ParameterSetName, "ScriptDefinition", StringComparison.OrdinalIgnoreCase))
313- // {
314- // diagnosticsList = ScriptAnalyzer.Instance.AnalyzeScriptDefinition(pathOrScriptDefinition);
315- // }
316-
317- // //Output through loggers
318- // foreach (ILogger logger in ScriptAnalyzer.Instance.Loggers)
319- // {
320- // foreach (DiagnosticRecord diagnostic in diagnosticsList)
321- // {
322- // logger.LogObject(diagnostic, this);
323- // }
324- // }
325- //}
326-
327307 #endregion
328308 }
329309}
0 commit comments