Ejemplo n.º 1
0
        public void InitializeProvider(PsRequest request)
        {
            if (request == null)
            {
                throw new ArgumentNullException("request");
            }

            request.Debug("Initializing PowerShell MetaProvider");

            //During the initialization, we load the PowerShellGet only to speeding up a little bit
            var psModules = ScanForPowerShellGetModule(request).WhereNotNull();

            foreach (var psModule in psModules)
            {
                //Check if the PowerShellGet provider exists
                if ((psModule.Key != null) && (psModule.Value != null))
                {
                    //load the PowerShellGet
                    AnalyzeModule(request, psModule.Key, psModule.Value.Version ?? new Version(0, 0), false, psModule.Value);
                }
            }

            if (_availableProviders.ContainsKey(PowerShellGet))
            {
                request.Debug("Loaded PowerShell Provider: PowerShellGet");
            }
            else
            {
                //if we can not load PowerShellGet, we do not fail the initialization
                request.Verbose(string.Format(CultureInfo.CurrentCulture, Resources.Messages.ModuleNotFound, PowerShellGet));
            }
        }
Ejemplo n.º 2
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.Verbose(string.Format(Resources.Messages.PackageManagementProvidersNotFound, baseFolder));
            }
        }
Ejemplo n.º 3
0
        public void InitializeProvider(PsRequest request) {
            if (request == null) {
                throw new ArgumentNullException("request");
            }

            request.Debug("Initializing PowerShell MetaProvider");

            //During the initialization, we load the PowerShellGet only to speeding up a little bit 
            var psModules = ScanForPowerShellGetModule(request).WhereNotNull();

            foreach (var psModule in psModules) {
                //Check if the PowerShellGet provider exists
                if ((psModule.Key != null) && (psModule.Value != null)) {
                    //load the PowerShellGet
                    AnalyzeModule(request, psModule.Key, psModule.Value.Version ?? new Version(0, 0), false, true, psModule.Value);
                }
            }

            if (_availableProviders.ContainsKey(PowerShellGet))
            {
                request.Debug("Loaded PowerShell Provider: PowerShellGet");
            }
            else
            {
                //if we can not load PowerShellGet, we do not fail the initialization
                request.Verbose(string.Format(CultureInfo.CurrentCulture, Resources.Messages.ModuleNotFound, PowerShellGet));
            }
        }
Ejemplo n.º 4
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));
            }
        }