/// <summary> /// Creates a new instance of <see cref="CommandLinePredictor"/>. /// </summary> /// <param name="modelPredictions">List of suggestions from the model, sorted by frequency (most to least).</param> /// <param name="parameterValuePredictor">Provide the prediction to the parameter values.</param> /// <param name="telemetryClient">The telemetry client.</param> /// <param name="azContext">The current PowerShell conext.</param> public CommandLinePredictor(IList <PredictiveCommand> modelPredictions, ParameterValuePredictor parameterValuePredictor, ITelemetryClient telemetryClient, IAzContext azContext = null) { Validation.CheckArgument(modelPredictions, $"{nameof(modelPredictions)} cannot be null."); _telemetryClient = telemetryClient; _parameterValuePredictor = parameterValuePredictor; var commnadLines = new List <CommandLine>(); if (modelPredictions != null) { for (var i = 0; i < modelPredictions.Count; ++i) { try { this._commandLinePredictions.Add(new CommandLine(modelPredictions[i], azContext)); } catch (Exception e) { _telemetryClient?.OnParseCommandLineFailure(new CommandLineParsingTelemetryData(modelPredictions[i].Command, e)); } } } }