Esempio n. 1
0
        public void GetInstalledPackages(string name, string requiredVersion, string minimumVersion, string maximumVersion, BootstrapRequest request)
        {
            if (request == null)
            {
                throw new ArgumentNullException("request");
            }

            request.Debug("Calling '{0}::GetInstalledPackages' '{1}','{2}','{3}','{4}'", PackageProviderName, name, requiredVersion, minimumVersion, maximumVersion);

            //search under the providerAssembies folder for the installed providers
            var providers = PackageManagementService.AllProvidersFromProviderAssembliesLocation(request).Select(providerFileAssembly => {
                //get the provider's name\version
                var versionFolder = Path.GetDirectoryName(providerFileAssembly);

                if (string.IsNullOrWhiteSpace(versionFolder))
                {
                    return(null);
                }

                Version ver;
                if (!Version.TryParse(Path.GetFileName(versionFolder), out ver))
                {
                    //this will cover whether the providerFileAssembly is at top level as well as a bad version folder
                    //skip if the provider is at the top level as they are imported already via LoadProviders() during the initialization.
                    //the provider will be handled PackageManagementService.DynamicProviders below.
                    return(null);
                }

                var providerNameFolder = Path.GetDirectoryName(versionFolder);
                if (!string.IsNullOrWhiteSpace(providerNameFolder))
                {
                    var providerName = Path.GetFileName(providerNameFolder);
                    if (!string.IsNullOrWhiteSpace(providerName))
                    {
                        return(new {
                            Name = providerName,
                            Version = (FourPartVersion)ver,
                            ProviderPath = providerFileAssembly
                        });
                    }
                }

                return(null);
            }).WhereNotNull();

            // return all the dynamic package providers as packages
            providers = providers.Concat(PackageManagementService.DynamicProviders.Select(each => new {
                Name = each.ProviderName,
                each.Version,
                each.ProviderPath
            })).Distinct();

            var pp = request.LocalSource.Any() ? providers.Select(each => request.GetProviderFromFile(each.ProviderPath, false, true)).WhereNotNull() :
                     providers.Select(each => request.GetProvider(each.Name, each.Version)).WhereNotNull();

            foreach (var p in pp)
            {
                request.YieldFromSwidtag(p, requiredVersion, minimumVersion, maximumVersion, name);
            }
        }
Esempio n. 2
0
        private void InstallPackageFromFile(string fastPath, BootstrapRequest request)
        {
            var filePath = new Uri(fastPath).LocalPath;

            var pkg = request.GetProviderFromFile(filePath, true, false);

            if (pkg != null)
            {
                InstallAssemblyProvider(pkg, null, filePath, request, false);
            }
        }
Esempio n. 3
0
        private void InstallPackageFromFile(string fastPath, BootstrapRequest request)
        {
            var filePath = new Uri(fastPath).LocalPath;

            var pkg = request.GetProviderFromFile(filePath, true, false);

            if (pkg != null) {
                InstallAssemblyProvider(pkg, null, filePath, request, false);
            }
        }
Esempio n. 4
0
        public void GetInstalledPackages(string name, string requiredVersion, string minimumVersion, string maximumVersion, BootstrapRequest request) {
            if (request == null) {
                throw new ArgumentNullException("request");
            }

            request.Debug("Calling '{0}::GetInstalledPackages' '{1}','{2}','{3}','{4}'", PackageProviderName, name, requiredVersion, minimumVersion, maximumVersion);

            //search under the providerAssemblies folder for the installed providers
            var providers = PackageManagementService.AllProvidersFromProviderAssembliesLocation(request).Select(providerFileAssembly => {
                          
                //get the provider's name\version
                var versionFolder = Path.GetDirectoryName(providerFileAssembly);

                if (string.IsNullOrWhiteSpace(versionFolder)) {
                    return null;
                }
 
                Version ver;
                if (!Version.TryParse(Path.GetFileName(versionFolder), out ver)) {
                    //this will cover whether the providerFileAssembly is at top level as well as a bad version folder
                    //skip if the provider is at the top level as they are imported already via LoadProviders() during the initialization. 
                    //the provider will be handled PackageManagementService.DynamicProviders below.
                    return null;
                }
                                              
                var providerNameFolder = Path.GetDirectoryName(versionFolder);
                if (!string.IsNullOrWhiteSpace(providerNameFolder)) {
                    var providerName = Path.GetFileName(providerNameFolder);
                    if (!string.IsNullOrWhiteSpace(providerName)) {
                        return new {
                            Name = providerName,
                            Version = (FourPartVersion)ver,
                            ProviderPath = providerFileAssembly
                        };
                    }
                }
                
                return null;
            }).WhereNotNull();

            // return all the dynamic package providers as packages
            providers = providers.Concat(PackageManagementService.DynamicProviders.Select(each => new {
                Name = each.ProviderName,
                each.Version,
                each.ProviderPath
            })).Distinct();

            var pp = request.LocalSource.Any() ? providers.Select(each => request.GetProviderFromFile(each.ProviderPath, false, true)).WhereNotNull() :
                                                                    providers.Select(each => request.GetProvider(each.Name, each.Version)).WhereNotNull();

            foreach (var p in pp) {
                request.YieldFromSwidtag(p, requiredVersion, minimumVersion, maximumVersion, name);
            }
        }