Пример #1
0
        public UncompressedPackage(IPackageRepository source,
            IFile originalPackageFile,
            IDirectory wrapCacheDirectory)
        {
            Check.NotNull(source, "source");
            if (originalPackageFile == null || originalPackageFile.Exists == false)
            {
                IsValid = false;
                return;
            }
            _originalPackageFile = originalPackageFile;
            BaseDirectory = wrapCacheDirectory;
            // get the descriptor file inside the package

            Source = source;
            var wrapDescriptor = wrapCacheDirectory.Files("*.wrapdesc").SingleOrDefault();

            if (wrapDescriptor == null)
            {
                IsValid = false;
                return;
            }

            var versionFile = wrapCacheDirectory.GetFile("version");
            _descriptor = new PackageDescriptorReaderWriter().Read(wrapDescriptor);
            PackageInfo = new DefaultPackageInfo(originalPackageFile.Name,
                                                versionFile.Exists ? versionFile.Read(x => x.ReadString().ToVersion()) : null,
                                                _descriptor);
            Identifier = new PackageIdentifier(Name, Version);
            IsValid = true;
        }
Пример #2
0
 public UncompressedPackage(IPackageRepository source,
     IFile originalPackageFile,
     IDirectory wrapCacheDirectory)
 {
     _originalPackageFile = originalPackageFile;
     BaseDirectory = wrapCacheDirectory;
     // get the descriptor file inside the package
     var descriptorName = originalPackageFile.NameWithoutExtension;
     Source = source;
     var wrapDescriptor = wrapCacheDirectory.Files("*.wrapdesc").SingleOrDefault();
     if (wrapDescriptor == null)
         throw new InvalidOperationException("Could not find descriptor in wrap cache directory, or there are multiple .wrapdesc files in the package.");
     var versionFile = wrapCacheDirectory.GetFile("version");
     _descriptor = new PackageDescriptorReaderWriter().Read(wrapDescriptor);
     PackageInfo = new DefaultPackageInfo(originalPackageFile.Name,
                                         versionFile.Exists ? versionFile.Read(x => x.ReadString().ToVersion()) : null,
                                         _descriptor);
     Identifier = new PackageIdentifier(Name, Version);
 }