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


C# IPackage.GetStream方法代码示例

本文整理汇总了C#中IPackage.GetStream方法的典型用法代码示例。如果您正苦于以下问题:C# IPackage.GetStream方法的具体用法?C# IPackage.GetStream怎么用?C# IPackage.GetStream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IPackage的用法示例。


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

示例1: AddPackage

        public void AddPackage(IPackage package)
        {
            // if the package is already present in the cache, no need to do anything
            if (FindPackage(package.Id, package.Version) != null)
            {
                return;
            }

            // create the cache directory if it doesn't exist
            var cacheDirectory = new DirectoryInfo(Source);
            if (!cacheDirectory.Exists)
            {
                cacheDirectory.Create();
            }

            // don't want to blow up user's hard drive with too many packages
            ClearCache(cacheDirectory, MaxNumberOfPackages);

            // now copy the package to the cache
            string filePath = GetPackageFilePath(package.Id, package.Version);
            using (Stream stream = package.GetStream(),
                          fileStream = File.Create(filePath))
            {
                if (stream != null)
                {
                    stream.CopyTo(fileStream);
                }
            }
        }
开发者ID:campersau,项目名称:NuGetPackageExplorer,代码行数:29,代码来源:MachineCache.cs

示例2: CreatePackage

        public Package CreatePackage(IPackage nugetPackage, User currentUser)
        {
            ValidateNuGetPackage(nugetPackage);

            var packageRegistration = CreateOrGetPackageRegistration(currentUser, nugetPackage);

            var package = CreatePackageFromNuGetPackage(packageRegistration, nugetPackage);
            packageRegistration.Packages.Add(package);

            using (var tx = new TransactionScope())
            {
                using (var stream = nugetPackage.GetStream())
                {
                    UpdateIsLatest(packageRegistration);
                    packageRegistrationRepo.CommitChanges();
                    packageFileSvc.SavePackageFile(package, stream);
                    tx.Complete();
                }
            }

            if (package.Status != PackageStatusType.Approved && package.Status != PackageStatusType.Exempted)
            {
                NotifyForModeration(package, comments: string.Empty);
            }

            NotifyIndexingService();

            return package;
        }
开发者ID:TomOne,项目名称:chocolatey.org,代码行数:29,代码来源:PackageService.cs

示例3: CopyNupkgToTargetPathAsync

        protected async Task CopyNupkgToTargetPathAsync(IPackage package)
        {
            var targetFile = new FileInfo(GetNupkgPath(package));

            if (targetFile.Directory != null && !targetFile.Directory.Exists)
            {
                targetFile.Directory.Create();
            }
            else if (targetFile.Exists)
            {
                targetFile.Delete();
            }

            var fastZipPackage = package as FastZipPackage;
            if (fastZipPackage != null)
            {
                File.Move(fastZipPackage.GetFileLocation(), targetFile.FullName);
                fastZipPackage.FileLocation = targetFile.FullName;
                return;
            }

            using (var sourceStream = package.GetStream())
            {
                using (var targetStream = targetFile.Open(FileMode.Create, FileAccess.Write))
                {
                    await sourceStream.CopyToAsync(targetStream);
                }
            }
        }
开发者ID:ompanda,项目名称:NuGet.Lucene,代码行数:29,代码来源:SymbolSource.cs

示例4: AddPackage

 public override void AddPackage(IPackage package)
 {
     string fileName = PathResolver.GetPackageFileName(package);
     using (Stream stream = package.GetStream())
     {
         FileSystem.AddFile(fileName, stream);
     }
 }
开发者ID:atheken,项目名称:nuget,代码行数:8,代码来源:ServerPackageRepository.cs

示例5: AddPackage

 public override void AddPackage(IPackage package)
 {
     //string fileName = PathResolver.GetPackageFileName(package);
     string fileName = PathResolver.GetInstallPath(package) + ".nupkg";
     using (Stream stream = package.GetStream())
     {
         FileSystem.AddFile(fileName, stream);
     }
 }
开发者ID:CloudMorph,项目名称:cloudmorph-fabric,代码行数:9,代码来源:ServerPackageRepository.cs

示例6: RetrieveTemporaryPackageFile

 protected string RetrieveTemporaryPackageFile(IPackage package)
 {
     var temporaryPath = Path.Combine(Path.GetTempPath(), string.Format("{0} {1}.nupkg", package.Id, package.Version));
     using (FileStream stream = new FileStream(temporaryPath, FileMode.OpenOrCreate))
     {
         package.GetStream().CopyTo(stream);
     }
     return temporaryPath;
 }
开发者ID:modulexcite,项目名称:dotpeek-nupeek,代码行数:9,代码来源:OpenFromNuGetHandlerBase.cs

示例7: PrepareSamplePackage

        public void PrepareSamplePackage()
        {
            package = LoadSamplePackage("Package", "1.0.0");
            
            using (var stream = package.GetStream())
            {
                packageSize = stream.Length;
            }

            server = new PackageServer(ServerUrl + "api/packages", "");
        }
开发者ID:battenworks,项目名称:NuGet.Lucene,代码行数:11,代码来源:PushTests.cs

示例8: AddPackage

 public void AddPackage(IPackage package)
 {
     _logger.Log(MessageLevel.Info, NuGetResources.MirrorCommandPushingPackage, package.GetFullName(), CommandLineUtility.GetSourceDisplayName(_destination.Source));
     _destination.PushPackage(
         _apiKey, 
         package, 
         package.GetStream().Length, 
         (int)_timeout.TotalMilliseconds, 
         disableBuffering: false);
     _logger.Log(MessageLevel.Info, NuGetResources.MirrorCommandPackagePushed);
 }
开发者ID:Newtopian,项目名称:nuget,代码行数:11,代码来源:PackageServerRepository.cs

示例9: PushPackage

    public void PushPackage(IPackage package)
    {
      var timeout = Convert.ToInt32(TimeSpan.FromMinutes(5).TotalMilliseconds);
#if !DEBUG
      using (var stream = package.GetStream())
      {
        var packageSize = stream.Length;
        _ps.PushPackage(ApiKey, package, packageSize, timeout, false);
      }
#endif

    }
开发者ID:talisker77,项目名称:Package.Util,代码行数:12,代码来源:LocalPackageRepository.cs

示例10: AddPackage

 public override void AddPackage(IPackage package)
 {
     string fileName = PathResolver.GetPackageFileName(package);
     if (FileSystem.FileExists(fileName) && !AllowOverrideExistingPackageOnPush)
     {
         throw new InvalidOperationException(String.Format(NuGetResources.Error_PackageAlreadyExists, package));
     }
     using (Stream stream = package.GetStream())
     {
         FileSystem.AddFile(fileName, stream);
     }
 }
开发者ID:riteshparekh,项目名称:NuGet,代码行数:12,代码来源:ServerPackageRepository.cs

示例11: Add

        public void Add(IPackage package)
        {
            var packageCache = PackageCacheLocation(package);

            _fileSystem.EnsureDirectoryExists(packageCache);

            var cachedPackagePath = Path.Combine(packageCache, CachedPackageVersionFilename(package.Id, package.Version.ToString()));

            if (CachedVersionExistsAndIsUpToDate(package, cachedPackagePath))
            {
                return;
            }

            Logger.InfoFormat("Downloading {0} to {1}.", package.Id, package);
            File.WriteAllBytes(cachedPackagePath, package.GetStream().ReadAllBytes());
            Logger.InfoFormat("Cached {0} to {1}.", package.Id, package);
        }
开发者ID:repne,项目名称:DeployD,代码行数:17,代码来源:NuGetPackageCache.cs

示例12: CopyNupkgToTargetPathAsync

        protected async Task CopyNupkgToTargetPathAsync(IPackage package)
        {
            var targetFile = new FileInfo(GetNupkgPath(package));

            if (targetFile.Directory != null && !targetFile.Directory.Exists)
            {
                targetFile.Directory.Create();
            }
            
            using (var sourceStream = package.GetStream())
            {
                using (var targetStream = targetFile.Open(FileMode.Create, FileAccess.Write))
                {
                    await sourceStream.CopyToAsync(targetStream);
                }
            }
        }
开发者ID:jjchiw,项目名称:NuGet.Lucene,代码行数:17,代码来源:SymbolSource.cs

示例13: CreatePackage

        public Package CreatePackage(IPackage nugetPackage, User currentUser)
        {
            ValidateNuGetPackage(nugetPackage);

            var packageRegistration = CreateOrGetPackageRegistration(currentUser, nugetPackage);

            var package = CreatePackageFromNuGetPackage(packageRegistration, nugetPackage);
            packageRegistration.Packages.Add(package);

            using (var tx = new TransactionScope())
            using (var stream = nugetPackage.GetStream())
            {
                packageRegistrationRepo.CommitChanges();
                packageFileSvc.SavePackageFile(package, stream);
                tx.Complete();
            }

            return package;
        }
开发者ID:aldion,项目名称:NuGetGallery,代码行数:19,代码来源:PackageService.cs

示例14: AddPackage

        public override void AddPackage(IPackage package)
        {
            // If we exceed the package count then clear the cache.
            var files = GetPackageFiles().ToList();
            if (files.Count >= MaxPackages)
            {
                // It's expensive to hit the file system to get the last accessed date for files
                // To reduce this cost from occuring frequently, we'll purge packages in batches allowing for a 20% buffer.
                var filesToDelete = files.OrderBy(FileSystem.GetLastAccessed)
                                         .Take(files.Count - (int)(0.8 * MaxPackages))
                                         .ToList();
                TryClear(filesToDelete);
            }

            string path = GetPackageFilePath(package);
            using (var stream = package.GetStream())
            {
                TryAct(() => FileSystem.AddFile(path, stream));
            }
        }
开发者ID:nickfloyd,项目名称:NuGet,代码行数:20,代码来源:MachineCache.cs

示例15: InstallPackage

        public void InstallPackage(IPackage package)
        {
            var directoryToExpandTo = Path.Combine(_localRepository.Source, package.Id);
            foreach (var file in package.GetContentFiles())
            {
                string pathWithoutContextPrefix = file.Path.Substring("content/".Length);
                var fullPath = Path.Combine(directoryToExpandTo, pathWithoutContextPrefix);
                Directory.CreateDirectory(Path.GetDirectoryName(fullPath));

                using (Stream writeStream = File.OpenWrite(fullPath),
                              readStream = file.GetStream())
                {
                    readStream.CopyTo(writeStream);
                }
            }

            var packageFile = Path.Combine(directoryToExpandTo, package.GetFullName() + ".nupkg");
            using (Stream readStream = package.GetStream(),
                          writeStream = File.OpenWrite(packageFile))
            {
                readStream.CopyTo(writeStream);
            }
        }
开发者ID:pranavkm,项目名称:SiteExtensions.Admin,代码行数:23,代码来源:WebProjectManager.cs


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