Inheritance: ICredentialProvider
		static void InitializeCredentialProvider()
		{
			ISettings settings = Settings.LoadDefaultSettings(null, null, null);
			var packageSourceProvider = new PackageSourceProvider(settings);
			var credentialProvider = new SettingsCredentialProvider(new SharpDevelopCredentialProvider(), packageSourceProvider);
			
			HttpClient.DefaultCredentialProvider = credentialProvider;
		}
Esempio n. 2
0
        private void Initialize(IFileSystem fileSystem, IConsole console)
        {
            using (var catalog = new AggregateCatalog(new AssemblyCatalog(GetType().Assembly)))
            {
                if (!IgnoreExtensions)
                {
                    AddExtensionsToCatalog(catalog, console);
                }
                using (var container = new CompositionContainer(catalog))
                {
                    var settings             = Settings.LoadDefaultSettings(fileSystem);
                    var defaultPackageSource = new PackageSource(NuGetConstants.DefaultFeedUrl);

                    var officialPackageSource = new PackageSource(NuGetConstants.DefaultFeedUrl, NuGetResources.OfficialPackageSourceName);
                    var v1PackageSource       = new PackageSource(NuGetConstants.V1FeedUrl, NuGetResources.OfficialPackageSourceName);
                    var legacyV2PackageSource = new PackageSource(NuGetConstants.V2LegacyFeedUrl, NuGetResources.OfficialPackageSourceName);

                    var packageSourceProvider = new PackageSourceProvider(
                        settings,
                        new[] { defaultPackageSource },
                        new Dictionary <PackageSource, PackageSource> {
                        { v1PackageSource, officialPackageSource },
                        { legacyV2PackageSource, officialPackageSource }
                    }
                        );

                    // Register an additional provider for the console specific application so that the user
                    // will be prompted if a proxy is set and credentials are required
                    var credentialProvider = new SettingsCredentialProvider(new ConsoleCredentialProvider(console), packageSourceProvider, console);
                    HttpClient.DefaultCredentialProvider = credentialProvider;

                    container.ComposeExportedValue <IConsole>(console);
                    container.ComposeExportedValue <ISettings>(settings);
                    container.ComposeExportedValue <IPackageRepositoryFactory>(new NuGet.Common.CommandLineRepositoryFactory());
                    container.ComposeExportedValue <IPackageSourceProvider>(packageSourceProvider);
                    container.ComposeExportedValue <ICredentialProvider>(credentialProvider);
                    container.ComposeExportedValue <IFileSystem>(fileSystem);
                    container.ComposeParts(this);
                }
            }
        }
Esempio n. 3
0
        private void Initialize(IFileSystem fileSystem, IConsole console)
        {
            using (var catalog = new AggregateCatalog(new AssemblyCatalog(GetType().Assembly)))
            {
                if (!IgnoreExtensions)
                {
                    AddExtensionsToCatalog(catalog);
                }
                using (var container = new CompositionContainer(catalog))
                {
                    var settings = GetCommandLineSettings(fileSystem);
                    var defaultPackageSource = new PackageSource(NuGetConstants.DefaultFeedUrl);

                    var officialPackageSource = new PackageSource(NuGetConstants.DefaultFeedUrl, NuGetResources.OfficialPackageSourceName);
                    var v1PackageSource = new PackageSource(NuGetConstants.V1FeedUrl, NuGetResources.OfficialPackageSourceName);
                    var legacyV2PackageSource = new PackageSource(NuGetConstants.V2LegacyFeedUrl, NuGetResources.OfficialPackageSourceName);

                    var packageSourceProvider = new PackageSourceProvider(
                        settings,
                        new[] { defaultPackageSource },
                        new Dictionary<PackageSource, PackageSource> { 
                            { v1PackageSource, officialPackageSource },
                            { legacyV2PackageSource, officialPackageSource }
                        }
                    );

                    // Register an additional provider for the console specific application so that the user
                    // will be prompted if a proxy is set and credentials are required
                    var credentialProvider = new SettingsCredentialProvider(new ConsoleCredentialProvider(), packageSourceProvider, console);
                    HttpClient.DefaultCredentialProvider = credentialProvider;

                    container.ComposeExportedValue<IConsole>(console);
                    container.ComposeExportedValue<ISettings>(settings);
                    container.ComposeExportedValue<IPackageRepositoryFactory>(new NuGet.Common.CommandLineRepositoryFactory());
                    container.ComposeExportedValue<IPackageSourceProvider>(packageSourceProvider);
                    container.ComposeExportedValue<ICredentialProvider>(credentialProvider);
                    container.ComposeParts(this);
                }
            }
        }