示例#1
0
        public ProjectId DecompileProject(PEFile moduleDefinition, string targetDirectory, TextWriter projectFileWriter, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (string.IsNullOrEmpty(targetDirectory))
            {
                throw new InvalidOperationException("Must set TargetDirectory");
            }
            TargetDirectory = targetDirectory;
            directories.Clear();
            var files = WriteCodeFilesInProject(moduleDefinition, cancellationToken).ToList();

            files.AddRange(WriteResourceFilesInProject(moduleDefinition));
            files.AddRange(WriteMiscellaneousFilesInProject(moduleDefinition));
            if (Settings.ProduceSourceCode && StrongNameKeyFile != null)
            {
                File.Copy(StrongNameKeyFile, Path.Combine(targetDirectory, Path.GetFileName(StrongNameKeyFile)), overwrite: true);
            }

            if (Settings.ProduceSourceCode)
            {
                projectWriter.Write(projectFileWriter, this, files, moduleDefinition);
            }

            string platformName = TargetServices.GetPlatformName(moduleDefinition);

            return(new ProjectId(platformName, ProjectGuid, ProjectTypeGuids.CSharpWindows));
        }
示例#2
0
        public ProjectId DecompileProject(PEFile moduleDefinition, string targetDirectory, TextWriter projectFileWriter, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (string.IsNullOrEmpty(targetDirectory))
            {
                throw new InvalidOperationException("Must set TargetDirectory");
            }
            TargetDirectory = targetDirectory;
            directories.Clear();
            var resources = WriteResourceFilesInProject(moduleDefinition).ToList();
            var files     = WriteCodeFilesInProject(moduleDefinition, resources.SelectMany(r => r.partialTypes ?? Enumerable.Empty <PartialTypeInfo>()).ToList(), cancellationToken).ToList();

            files.AddRange(resources.Select(r => (r.itemType, r.fileName)));
            files.AddRange(WriteMiscellaneousFilesInProject(moduleDefinition));
            if (StrongNameKeyFile != null)
            {
                File.Copy(StrongNameKeyFile, Path.Combine(targetDirectory, Path.GetFileName(StrongNameKeyFile)), overwrite: true);
            }

            projectWriter.Write(projectFileWriter, this, files, moduleDefinition);

            string platformName = TargetServices.GetPlatformName(moduleDefinition);

            return(new ProjectId(platformName, ProjectGuid, ProjectTypeGuids.CSharpWindows));
        }