Ejemplo n.º 1
0
        private IEnumerable<KeyValuePair<string,PSModuleInfo>> ScanPrivateDataForProviders(PsRequest request, string baseFolder, Hashtable privateData, PSModuleInfo moduleInfo) {
            var providers = privateData.GetStringCollection("PackageManagementProviders").ReEnumerable();
            if (providers.Any()) {
                // found a module that is advertizing one or more  Providers.

                foreach (var provider in providers) {
                    var fullPath = provider;
                    try {
                        if (!Path.IsPathRooted(provider)) {
                            fullPath = Path.GetFullPath(Path.Combine(baseFolder, provider));
                        }
                    } catch {
                        // got an error from the path.
                        continue;
                    }
                    if (Directory.Exists(fullPath) || File.Exists(fullPath)) {
                        // looks like we have something that could definitely be a
                        // a module path.
                        var result = new KeyValuePair<string, PSModuleInfo>(fullPath, moduleInfo);
                        AddToPowerShellProviderCacheTable(result);
                        yield return result;
                    } else {
                        request.Verbose(string.Format(CultureInfo.CurrentCulture, Resources.Messages.FileNotFound, fullPath));
                    }
                }
            } else {
                request.Debug(string.Format(Resources.Messages.PackageManagementProvidersNotFound, baseFolder));
            }
        }