public static void Process(Logger logger, IEnumerable <string> inPlaceFiles, IEnumerable <string> templateFiles, IEnumerable <string> templateIncludeFiles, IEnumerable <string> templaceLibraryFiles, IEnumerable <string> dependencyPaths, string absoluteOutputDir, out List <string> compileGeneratedFiles, out List <string> embeddedResourceGeneratedFiles, out List <string> filesToDelete, bool createNewAppDomain, bool debugMode, string conditionalCompilationSymbols) { compileGeneratedFiles = new List <string>(); embeddedResourceGeneratedFiles = new List <string>(); filesToDelete = new List <string>(); try { PreSharpGenerator generator = new PreSharpGenerator(); generator.Init(debugMode, logger, dependencyPaths, conditionalCompilationSymbols, absoluteOutputDir); if (templaceLibraryFiles != null && templaceLibraryFiles.Any()) { string libraryAssembly = Path.GetTempFileName(); File.Delete(libraryAssembly); libraryAssembly = Path.ChangeExtension(libraryAssembly, ".dll"); if (generator.GenerateLibraryAssemblyFromTemplateLibraryFiles(templaceLibraryFiles, libraryAssembly, compileGeneratedFiles)) { filesToDelete.Add(libraryAssembly); generator.AddReference(libraryAssembly); } } if (createNewAppDomain) { AppDomain domain = AppDomain.CreateDomain("PreSharp Temporary Domain"); try { PreSharpGenerator newGenerator = (PreSharpGenerator)domain.CreateInstanceFromAndUnwrap( Assembly.GetExecutingAssembly().Location, typeof(PreSharpGenerator).FullName); newGenerator.Init(debugMode, logger, dependencyPaths, conditionalCompilationSymbols, absoluteOutputDir); foreach (var reference in generator.References) { newGenerator.AddReference(reference); } newGenerator.ProcessInplaceFiles(inPlaceFiles, compileGeneratedFiles); newGenerator.ProcessTemplateFiles(templateFiles, templateIncludeFiles, compileGeneratedFiles, embeddedResourceGeneratedFiles); } finally { AppDomain.Unload(domain); } } else { generator.ProcessInplaceFiles(inPlaceFiles, compileGeneratedFiles); generator.ProcessTemplateFiles(templateFiles, templateIncludeFiles, compileGeneratedFiles, embeddedResourceGeneratedFiles); } } catch (Exception e) { logger.LogException(null, e); } }
public static void Process(Logger logger, IEnumerable<string> inPlaceFiles, IEnumerable<string> templateFiles, IEnumerable<string> templateIncludeFiles, IEnumerable<string> templaceLibraryFiles, IEnumerable<string> dependencyPaths, string absoluteOutputDir, out List<string> compileGeneratedFiles, out List<string> embeddedResourceGeneratedFiles, out List<string> filesToDelete, bool createNewAppDomain, bool debugMode, string conditionalCompilationSymbols) { compileGeneratedFiles = new List<string>(); embeddedResourceGeneratedFiles = new List<string>(); filesToDelete = new List<string>(); try { PreSharpGenerator generator = new PreSharpGenerator(); generator.Init(debugMode, logger, dependencyPaths, conditionalCompilationSymbols, absoluteOutputDir); if (templaceLibraryFiles != null && templaceLibraryFiles.Any()) { string libraryAssembly = Path.GetTempFileName(); File.Delete(libraryAssembly); libraryAssembly = Path.ChangeExtension(libraryAssembly, ".dll"); if (generator.GenerateLibraryAssemblyFromTemplateLibraryFiles(templaceLibraryFiles, libraryAssembly, compileGeneratedFiles)) { filesToDelete.Add(libraryAssembly); generator.AddReference(libraryAssembly); } } if (createNewAppDomain) { AppDomain domain = AppDomain.CreateDomain("PreSharp Temporary Domain"); try { PreSharpGenerator newGenerator = (PreSharpGenerator)domain.CreateInstanceFromAndUnwrap( Assembly.GetExecutingAssembly().Location, typeof(PreSharpGenerator).FullName); newGenerator.Init(debugMode, logger, dependencyPaths, conditionalCompilationSymbols, absoluteOutputDir); foreach (var reference in generator.References) { newGenerator.AddReference(reference); } newGenerator.ProcessInplaceFiles(inPlaceFiles, compileGeneratedFiles); newGenerator.ProcessTemplateFiles(templateFiles, templateIncludeFiles, compileGeneratedFiles, embeddedResourceGeneratedFiles); } finally { AppDomain.Unload(domain); } } else { generator.ProcessInplaceFiles(inPlaceFiles, compileGeneratedFiles); generator.ProcessTemplateFiles(templateFiles, templateIncludeFiles, compileGeneratedFiles, embeddedResourceGeneratedFiles); } } catch (Exception e) { logger.LogException(null, e); } }