public void InitializeProvider(PsRequest request) { if (request == null) { throw new ArgumentNullException("request"); } request.Debug("Initializing PowerShell MetaProvider"); var modules = ScanForModules(request).Distinct().ToArray(); // try to create each module at least once. modules.ParallelForEach(modulePath => AnalyzeModule(request, modulePath)); request.Debug("Loaded PowerShell Provider Modules "); }
private void AnalyzeModule(PsRequest request, KeyValuePair <string, string> modulePath) { request.Debug("Attempting to load PowerShell Provider Module [{0}]", modulePath); var provider = Create(request, modulePath); if (provider != null) { if (provider.GetPackageProviderName() != null) { request.Debug("Loaded PowerShell Package Provider Module: [{0}]", modulePath); // looks good to me, let's add this to the list of moduels this meta provider can create. _packageProviders.AddOrSet(provider.GetPackageProviderName(), provider); } else { provider.Dispose(); provider = null; } } }
// lock is on this instance only internal void ReportErrors(PsRequest request, IEnumerable <ErrorRecord> errors) { foreach (var error in errors) { request.Error(error.FullyQualifiedErrorId, error.CategoryInfo.Category.ToString(), error.TargetObject == null ? null : error.TargetObject.ToString(), error.ErrorDetails == null ? error.Exception.Message : error.ErrorDetails.Message); if (!string.IsNullOrWhiteSpace(error.ScriptStackTrace)) { // give a debug hint if we have a script stack trace. How nice of us. request.Debug(Constants.ScriptStackTrace, error.ScriptStackTrace); } } }
// lock is on this instance only internal void ReportErrors(PsRequest request, IEnumerable<ErrorRecord> errors) { foreach (var error in errors) { request.Error(error.FullyQualifiedErrorId, error.CategoryInfo.Category.ToString(), error.TargetObject == null ? null : error.TargetObject.ToString(), error.ErrorDetails == null ? error.Exception.Message : error.ErrorDetails.Message); if (!string.IsNullOrWhiteSpace(error.ScriptStackTrace)) { // give a debug hint if we have a script stack trace. How nice of us. request.Debug(Constants.ScriptStackTrace, error.ScriptStackTrace); } } }