Exemple #1
0
        private void ExpandFiles(IPackage package)
        {
            IBatchProcessor <string> fileSystem = this.FileSystem as IBatchProcessor <string>;

            try
            {
                IPackage            package2;
                List <IPackageFile> files = package.GetFiles().ToList <IPackageFile>();
                if (fileSystem != null)
                {
                    fileSystem.BeginProcessing(from p in files select p.Path, PackageAction.Install);
                }
                this.FileSystem.AddFiles(files, this.PathResolver.GetPackageDirectory(package));
                if (PackageHelper.IsSatellitePackage(package, this.LocalRepository, null, out package2))
                {
                    IEnumerable <IPackageFile> satelliteFiles = package.GetSatelliteFiles();
                    this.FileSystem.AddFiles(satelliteFiles, this.PathResolver.GetPackageDirectory(package2));
                }
            }
            finally
            {
                if (fileSystem != null)
                {
                    fileSystem.EndProcessing();
                }
            }
        }
        private void ExpandFiles(IPackage package)
        {
            IBatchProcessor <string> fileSystem = this.FileSystem as IBatchProcessor <string>;

            try
            {
                List <IPackageFile> list = package.GetFiles().ToList();
                if (fileSystem != null)
                {
                    fileSystem.BeginProcessing(
                        list.Select(p => p.Path),
                        PackageAction.Install);
                }
                string packageDirectory = this.PathResolver.GetPackageDirectory(package);
                this.FileSystem.AddFiles(list, packageDirectory);
                IPackage runtimePackage;
                if (!PackageHelper.IsSatellitePackage(package, this.LocalRepository, this.targetFrameWork, out runtimePackage))
                {
                    return;
                }
                this.FileSystem.AddFiles(package.GetSatelliteFiles(), this.PathResolver.GetPackageDirectory(runtimePackage));
            }
            finally
            {
                if (fileSystem != null)
                {
                    fileSystem.EndProcessing();
                }
            }
        }
Exemple #3
0
        public static void AddFiles(this IProjectSystem project, IEnumerable <IPackageFile> files, IDictionary <FileTransformExtensions, IPackageFileTransformer> fileTransformers)
        {
            List <IPackageFile>      list     = files.ToList <IPackageFile>();
            IComparer <IPackageFile> comparer = project as IComparer <IPackageFile>;

            if (comparer != null)
            {
                list.Sort(comparer);
            }
            IBatchProcessor <string> processor = project as IBatchProcessor <string>;

            try
            {
                if (processor != null)
                {
                    processor.BeginProcessing(from file in list select ResolvePath(fileTransformers, fte => fte.InstallExtension, file.EffectivePath), PackageAction.Install);
                }
                foreach (IPackageFile file in list)
                {
                    IPackageFileTransformer transformer;
                    if (file.IsEmptyFolder())
                    {
                        continue;
                    }
                    string path = ResolveTargetPath(project, fileTransformers, fte => fte.InstallExtension, file.EffectivePath, out transformer);
                    if (project.IsSupportedFile(path))
                    {
                        string str2;
                        if (transformer != null)
                        {
                            transformer.TransformFile(file, path, project);
                            continue;
                        }
                        if (FindFileTransformer(fileTransformers, fte => fte.UninstallExtension, file.EffectivePath, out str2) == null)
                        {
                            TryAddFile(project, path, new Func <Stream>(file.GetStream));
                        }
                    }
                }
            }
            finally
            {
                if (processor != null)
                {
                    processor.EndProcessing();
                }
            }
        }
Exemple #4
0
        public static void DeleteFiles(this IProjectSystem project, IEnumerable <IPackageFile> files, IEnumerable <IPackage> otherPackages, IDictionary <FileTransformExtensions, IPackageFileTransformer> fileTransformers)
        {
            IPackageFileTransformer        transformer;
            ILookup <string, IPackageFile> lookup = Enumerable.ToLookup <IPackageFile, string>(files, p => Path.GetDirectoryName(ResolveTargetPath(project, fileTransformers, fte => fte.UninstallExtension, p.EffectivePath, out transformer)));

            foreach (string str in from grouping in lookup
                     from directory in FileSystemExtensions.GetDirectories(grouping.Key)
                     orderby directory.Length descending
                     select directory)
            {
                IEnumerable <IPackageFile> enumerable = lookup.Contains(str) ? lookup[str] : Enumerable.Empty <IPackageFile>();
                if (project.DirectoryExists(str))
                {
                    IBatchProcessor <string> processor = project as IBatchProcessor <string>;
                    try
                    {
                        if (processor != null)
                        {
                            Func <IPackageFile, string> < > 9__6;
                            Func <IPackageFile, string> func5 = < > 9__6;
                            if (< > 9__6 == null)
                            {
                                Func <IPackageFile, string> local5 = < > 9__6;
                                func5 = < > 9__6 = file => ResolvePath(fileTransformers, fte => fte.UninstallExtension, file.EffectivePath);
                            }
                            processor.BeginProcessing(Enumerable.Select <IPackageFile, string>(enumerable, func5), PackageAction.Uninstall);
                        }
                        foreach (IPackageFile file in enumerable)
                        {
                            if (!file.IsEmptyFolder())
                            {
                                string path = ResolveTargetPath(project, fileTransformers, fte => fte.UninstallExtension, file.EffectivePath, out transformer);
                                if (project.IsSupportedFile(path))
                                {
                                    Func <IPackage, IEnumerable <IPackageFile> > < > 9__9;
                                    if (transformer == null)
                                    {
                                        project.DeleteFileSafe(path, new Func <Stream>(file.GetStream));
                                        continue;
                                    }
                                    Func <IPackage, IEnumerable <IPackageFile> > func4 = < > 9__9;
                                    if (< > 9__9 == null)
                                    {
                                        Func <IPackage, IEnumerable <IPackageFile> > local7 = < > 9__9;
                                        func4 = < > 9__9 = p => project.GetCompatibleItemsCore <IPackageFile>(p.GetContentFiles());
                                    }
                                    IEnumerable <IPackageFile> matchingFiles = from <> h__TransparentIdentifier0 in Enumerable.SelectMany(otherPackages, func4, (p, otherFile) => new {
                                        p         = p,
                                        otherFile = otherFile
                                    })
                                                                               where < > h__TransparentIdentifier0.otherFile.EffectivePath.Equals(file.EffectivePath, StringComparison.OrdinalIgnoreCase)
                                                                               select <> h__TransparentIdentifier0.otherFile;
                                    try
                                    {
                                        transformer.RevertFile(file, path, matchingFiles, project);
                                    }
                                    catch (Exception exception)
                                    {
                                        project.Logger.Log(MessageLevel.Warning, exception.Message, new object[0]);
                                    }
                                }
                            }
                        }
                        if (!project.GetFilesSafe(str).Any <string>() && !project.GetDirectoriesSafe(str).Any <string>())
                        {
                            project.DeleteDirectorySafe(str, false);
                        }
                    }
                    finally
                    {
                        if (processor != null)
                        {
                            processor.EndProcessing();
                        }
                    }
                }
            }
        }