当前位置: 首页>>代码示例>>C#>>正文


C# PackageSource类代码示例

本文整理汇总了C#中PackageSource的典型用法代码示例。如果您正苦于以下问题:C# PackageSource类的具体用法?C# PackageSource怎么用?C# PackageSource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


PackageSource类属于命名空间,在下文中一共展示了PackageSource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestSourceRepoPackageSourcesChanged

        public void TestSourceRepoPackageSourcesChanged()
        {
            // Arrange
            var localAppDataPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
            var localPackageSource = new PackageSource(localAppDataPath);
            var oldPackageSources = new List<PackageSource>() { localPackageSource };
            var packageSourceProvider = new TestPackageSourceProvider(oldPackageSources);
            var sourceRepositoryProvider = TestSourceRepositoryUtility.CreateSourceRepositoryProvider(packageSourceProvider);

            // Act
            var oldEffectivePackageSources = sourceRepositoryProvider.GetRepositories().ToList();

            // Assert
            Assert.Equal(1, oldEffectivePackageSources.Count);
            Assert.Equal(localAppDataPath, oldEffectivePackageSources[0].PackageSource.Source);

            // Main Act
            var newPackageSources = new List<PackageSource>() { TestSourceRepositoryUtility.V3PackageSource, localPackageSource };
            packageSourceProvider.SavePackageSources(newPackageSources);

            var newEffectivePackageSources = sourceRepositoryProvider.GetRepositories().ToList();

            // Main Assert
            Assert.Equal(2, newEffectivePackageSources.Count);
            Assert.Equal(TestSourceRepositoryUtility.V3PackageSource.Source, newEffectivePackageSources[0].PackageSource.Source);
            Assert.Equal(localAppDataPath, newEffectivePackageSources[1].PackageSource.Source);
        }
开发者ID:pabomex,项目名称:NuGet.PackageManagement,代码行数:27,代码来源:SourceRepositoryProviderTests.cs

示例2: CreateAction

		void CreateAction (
			string packageId = "Test",
			string version = "2.1")
		{
			project = new FakeDotNetProject (@"d:\projects\MyProject\MyProject.csproj");
			solutionManager = new FakeSolutionManager ();
			nugetProject = new FakeNuGetProject (project);
			solutionManager.NuGetProjects[project] = nugetProject;

			var repositoryProvider = solutionManager.SourceRepositoryProvider;
			var source = new PackageSource ("http://test.com");
			repositoryProvider.AddRepository (source);
			primaryRepositories = repositoryProvider.Repositories;

			action = new TestableReinstallNuGetPackageAction (
				project,
				solutionManager);

			packageManagementEvents = action.PackageManagementEvents;
			fileRemover = action.FileRemover;

			action.PackageId = packageId;
			action.Version = new NuGetVersion (version);

			uninstallPackageManager = action.UninstallAction.PackageManager;
			installPackageManager = action.InstallAction.PackageManager;
		}
开发者ID:sushihangover,项目名称:monodevelop,代码行数:27,代码来源:ReinstallNuGetPackageActionTests.cs

示例3: CreateRepository

        public virtual IPackageRepository CreateRepository(PackageSource packageSource)
        {
            if (packageSource == null) {
                throw new ArgumentNullException("packageSource");
            }

            if (packageSource.IsAggregate) {
                throw new NotSupportedException();
            }

            Uri uri = new Uri(packageSource.Source);
            if (uri.IsFile) {
                return new LocalPackageRepository(uri.LocalPath);
            }

            try {
                uri = _httpClient.GetRedirectedUri(uri);
            }
            catch (Exception exception) {
                throw new InvalidOperationException(
                    String.Format(CultureInfo.CurrentCulture,
                    NuGetResources.UnavailablePackageSource, packageSource),
                    exception);
            }

            // Make sure we get resolve any fwlinks before creating the repository
            return new DataServicePackageRepository(uri, _httpClient);
        }
开发者ID:jerriclynsjohn,项目名称:nuget,代码行数:28,代码来源:PackageRepositoryFactory.cs

示例4: CreateAction

		void CreateAction (
			string packageId = "Test",
			string version = "2.1")
		{
			project = new FakeDotNetProject (@"d:\projects\MyProject\MyProject.csproj");
			solutionManager = new FakeSolutionManager ();
			nugetProject = new FakeNuGetProject (project);
			solutionManager.NuGetProjects[project] = nugetProject;

			var metadataResourceProvider = new FakePackageMetadataResourceProvider ();
			packageMetadataResource = metadataResourceProvider.PackageMetadataResource;
			var source = new PackageSource ("http://test.com");
			var providers = new INuGetResourceProvider[] {
				metadataResourceProvider
			};
			var sourceRepository = new SourceRepository (source, providers);
			primaryRepositories = new [] {
				sourceRepository
			}.ToList ();

			action = new TestableInstallNuGetPackageAction (
				primaryRepositories,
				solutionManager,
				project);

			packageManager = action.PackageManager;
			packageManagementEvents = action.PackageManagementEvents;
			fileRemover = action.FileRemover;

			action.PackageId = packageId;
			action.Version = new NuGetVersion (version);
		}
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:32,代码来源:InstallNuGetPackageActionTests.cs

示例5: Create

        public override async Task<Resource> Create(PackageSource source)
        {
            try
            {
                object repo = null;
                string host = "TestHost";

                // Check if the source is already present in the cache.
                if (!packageSourceCache.TryGetValue(source.Url, out repo))
                {
                    // if it's not in cache, then check if it is V2.
                    if (await V2Utilities.IsV2(source))
                    {
                        // Get a IPackageRepo object and add it to the cache.
                        repo = V2Utilities.GetV2SourceRepository(source, host);
                        packageSourceCache.Add(source.Url, repo);
                    }
                    else
                    {
                        // if it's not V2, returns null
                        return null;
                    }
                }

                // Create a resource and return it.
                var resource = new V2Resource((IPackageRepository)repo, host);
                return resource;
            }
            catch (Exception)
            {
                // *TODOs:Do tracing and throw apppropriate exception here.
                return null; 
            }
        }
开发者ID:sistoimenov,项目名称:NuGet2,代码行数:34,代码来源:V2ResourceProvider.cs

示例6: CreateV3PreviewSource

 private static PackageSource CreateV3PreviewSource()
 {
     var source = new PackageSource(
         Strings.VsSourceRepositoryManager_V3SourceName,
         NuGetConstants.V3FeedUrl);
     return source;
 }
开发者ID:sistoimenov,项目名称:NuGet2,代码行数:7,代码来源:VsSourceRepositoryManager.cs

示例7: TryGetCredentialAndProxy

		private HttpMessageHandler TryGetCredentialAndProxy(PackageSource packageSource) 
        {
            Uri uri = new Uri(packageSource.Source);
            var proxy = ProxyCache.Instance.GetProxy(uri);
            var credential = CredentialStore.Instance.GetCredentials(uri);

            if (proxy != null && proxy.Credentials == null) {
                proxy.Credentials = CredentialCache.DefaultCredentials;
            }

            if (credential == null && !String.IsNullOrEmpty(packageSource.UserName) && !String.IsNullOrEmpty(packageSource.Password)) 
            {
                var cache = new CredentialCache();
                foreach (var scheme in _authenticationSchemes)
                {
                    cache.Add(uri, scheme, new NetworkCredential(packageSource.UserName, packageSource.Password));
                }
                credential = cache;
            }

            if (proxy == null && credential == null) return null;
            else
            {
                if(proxy != null) ProxyCache.Instance.Add(proxy);
                if (credential != null) CredentialStore.Instance.Add(uri, credential);
                return new WebRequestHandler()
                {
                    Proxy = proxy,
                    Credentials = credential
                };
            }


        }
开发者ID:michaelstaib,项目名称:NuGet.Protocol,代码行数:34,代码来源:HttpHandlerResourceV3Provider.cs

示例8: TryLoad

 public static bool TryLoad(string uriOrPath, out PackageSource packageSource)
 {
     try
     {
         Uri path;
         if (!Uri.TryCreate(uriOrPath, UriKind.RelativeOrAbsolute, out path))
         {
             packageSource = null;
             return false;
         }
         var resolvedPath = path.IsAbsoluteUri ? path.LocalPath : uriOrPath;
         if (File.Exists(resolvedPath))
         {
             packageSource = PackageSource.FromJson(File.OpenRead(resolvedPath), uriOrPath);
             return true;
         }
     }
     catch (Exception e)
     {
         // TODO: proper logging
         if (Environment.IsDebug)
         {
             Console.Error.WriteLine($"Unable to load local file index '{uriOrPath}'");
             Console.Error.WriteLine(e);
         }
     }
     packageSource = null;
     return false;
 }
开发者ID:mattolenik,项目名称:winston,代码行数:29,代码来源:LocalFileIndex.cs

示例9: IsV2

        public static async Task<bool> IsV2(PackageSource source)
        {
            var url = new Uri(source.Url);

            // If the url is a directory, then it's a V2 source
            if (url.IsFile || url.IsUnc) 
            {
                return !File.Exists(url.LocalPath);
            }

            using (var client = new Data.DataClient())
            {
                var result = await client.GetFile(url);
                if (result == null)
                {
                    return false;
                }

                var raw = result.Value<string>("raw");
                if (raw != null && raw.IndexOf("Packages", StringComparison.OrdinalIgnoreCase) != -1)
                {
                    return true;
                }

                return false;
            }
        }
开发者ID:sistoimenov,项目名称:NuGet2,代码行数:27,代码来源:V2Utilities.cs

示例10: CreateAction

		void CreateAction ()
		{
			project = new FakeDotNetProject (@"d:\projects\MyProject\MyProject.csproj");
			solutionManager = new FakeSolutionManager ();
			nugetProject = new FakeNuGetProject (project);
			solutionManager.NuGetProjects[project] = nugetProject;

			var metadataResourceProvider = new FakePackageMetadataResourceProvider ();
			packageMetadataResource = metadataResourceProvider.PackageMetadataResource;
			var source = new PackageSource ("http://test.com");
			var providers = new INuGetResourceProvider[] {
				metadataResourceProvider
			};
			var sourceRepository = new SourceRepository (source, providers);
			primaryRepositories = new [] {
				sourceRepository
			}.ToList ();
			solutionManager.SourceRepositoryProvider.Repositories.AddRange (primaryRepositories);

			action = new TestableUpdateAllNuGetPackagesInProjectAction (
				solutionManager,
				project);

			packageManager = action.PackageManager;
			packageManagementEvents = action.PackageManagementEvents;
			fileRemover = action.FileRemover;
			restoreManager = action.RestoreManager;
		}
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:28,代码来源:UpdateAllNuGetPackagesInProjectActionTests.cs

示例11: RemoteV2FindPackageByIdResourcce

        public RemoteV2FindPackageByIdResourcce(PackageSource packageSource)
        {
            _baseUri = packageSource.Source.EndsWith("/") ? packageSource.Source : (packageSource.Source + "/");
            _httpSource = new HttpSource(new Uri(_baseUri), packageSource.UserName, packageSource.Password);

            PackageSource = packageSource;
        }
开发者ID:eerhardt,项目名称:NuGet3,代码行数:7,代码来源:RemoteV2FindPackageByIdResource.cs

示例12: AddFromExtension

        public void AddFromExtension(ISourceRepositoryProvider provider, string extensionId)
        {
            string path = GetExtensionRepositoryPath(extensionId, null, _errorHandler);

            PackageSource source = new PackageSource(path);

            _repositories.Add(provider.CreateRepository(source));
        }
开发者ID:mauroa,项目名称:NuGet.VisualStudioExtension,代码行数:8,代码来源:PreinstalledRepositoryProvider.cs

示例13: AddFromRegistry

        public void AddFromRegistry(string keyName)
        {
            string path = GetRegistryRepositoryPath(keyName, null, _errorHandler);

            PackageSource source = new PackageSource(path);

            _repositories.Add(_provider.CreateRepository(source));
        }
开发者ID:mauroa,项目名称:NuGet.VisualStudioExtension,代码行数:8,代码来源:PreinstalledRepositoryProvider.cs

示例14: CreateRepository

		public IPackageRepository CreateRepository(PackageSource packageSource)
		{
			IPackageRepository repository = GetExistingRepository(packageSource);
			if (repository != null) {
				return repository;
			}
			return CreateNewCachedRepository(packageSource);
		}
开发者ID:kleinux,项目名称:SharpDevelop,代码行数:8,代码来源:PackageRepositoryCache.cs

示例15: RegisteredPackageSource

		public RegisteredPackageSource(PackageSource packageSource)
		{
			Source = packageSource.Source;
			Name = packageSource.Name;
			IsEnabled = packageSource.IsEnabled;
			UserName = packageSource.UserName;
			Password = packageSource.Password;
		}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:8,代码来源:RegisteredPackageSource.cs


注:本文中的PackageSource类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。