コード例 #1
0
ファイル: Repository.cs プロジェクト: ryanrousseau/Wyam
        public void InstallPackages(string absolutePackagesPath, DirectoryPath contentPath, IConfigurableFileSystem fileSystem, bool updatePackages)
        {
            PackageManager packageManager = new PackageManager(_packageRepository, absolutePackagesPath);

            // On package install...
            packageManager.PackageInstalled += (sender, args) =>
            {
                IDirectory packageContentDirectory = fileSystem.GetRootDirectory(contentPath.Combine(args.Package.Id));

                // Copy all content files on install and add to input paths
                bool firstFile = true;
                foreach (IPackageFile packageFile in args.Package.GetContentFiles())
                {
                    if (firstFile)
                    {
                        // This package does have content files, so create the directory and add an input path
                        packageContentDirectory.Create();
                        fileSystem.InputPaths.Insert(0, packageContentDirectory.Path);
                        firstFile = false;
                    }

                    IFile file = packageContentDirectory.GetFile(packageFile.EffectivePath);
                    file.Directory.Create();
                    using (var fileStream = file.Open(FileMode.Create))
                    {
                        packageFile.GetStream().CopyTo(fileStream);
                    }
                }
            };

            // On package uninstall...
            packageManager.PackageUninstalling += (sender, args) =>
            {
                IDirectory packageContentDirectory = fileSystem.GetRootDirectory(contentPath.Combine(args.Package.Id));
                packageContentDirectory.Delete(true);
            };

            // Install the packages
            foreach (Package package in _packages)
            {
                package.InstallPackage(packageManager, updatePackages);
            }
        }
コード例 #2
0
ファイル: DirectoryPathTests.cs プロジェクト: ibebbs/Wyam
            public void ShouldThrowIfPathIsNull()
            {
                // Given
                DirectoryPath path = new DirectoryPath("assets");

                // When
                TestDelegate test = () => path.Combine(null);

                // Then
                Assert.Throws<ArgumentNullException>(test);
            }
コード例 #3
0
ファイル: DirectoryPathTests.cs プロジェクト: ibebbs/Wyam
            public void CombiningWithAbsolutePathKeepsSecondProvider(string first, string second)
            {
                // Given
                DirectoryPath path = new DirectoryPath(new Uri("first:///"), first);

                // When
                DirectoryPath result = path.Combine(new DirectoryPath(new Uri("second:///"), second));

                // Then
                Assert.AreEqual(new Uri("second:///"), result.FileProvider);
            }
コード例 #4
0
ファイル: DirectoryPathTests.cs プロジェクト: ibebbs/Wyam
            public void CombiningWithRelativePathKeepsFirstProvider(string first, string second)
            {
                // Given
                DirectoryPath path = new DirectoryPath(new Uri("foo:///"), first);

                // When
                DirectoryPath result = path.Combine(new DirectoryPath(second));

                // Then
                Assert.AreEqual(new Uri("foo:///"), result.FileProvider);
            }
コード例 #5
0
ファイル: DirectoryPathTests.cs プロジェクト: ibebbs/Wyam
            public void ShouldCombinePaths(string first, string second, string expected)
            {
                // Given
                DirectoryPath path = new DirectoryPath(first);

                // When
                DirectoryPath result = path.Combine(new DirectoryPath(second));

                // Then
                Assert.AreEqual(expected, result.FullPath);
            }
コード例 #6
0
ファイル: WyamFolderNuGetProject.cs プロジェクト: ibebbs/Wyam
 // Add content directories to the input paths
 private void IncludeContentDirectories(DirectoryPath installedPath, PackageArchiveReader archiveReader)
 {
     FrameworkSpecificGroup contentGroup = GetMostCompatibleGroup(_reducer,
         _currentFramework, archiveReader.GetContentItems().ToList());
     if (contentGroup != null)
     {
         // We need to use the directory name from an actual file to make sure we get the casing right
         foreach (string contentSegment in contentGroup.Items
             .Select(x => new FilePath(x).Segments[0])
             .Distinct())
         {
             DirectoryPath contentPath = installedPath.Combine(contentSegment);
             _fileSystem.InputPaths.Insert(0, contentPath);
             Trace.Verbose($"Added content path {contentPath} to included paths");
         }
     }
 }