コード例 #1
0
        public GeneratedAssemblyInfo Compile(string sourcePath, string fileName = null)
        {
            fileName = fileName ?? FileName;
            CompilerResults compileResult = AdHocCSharpCompiler.CompileDirectory(new DirectoryInfo(sourcePath), fileName, ReferenceAssemblyPaths, false);

            if (compileResult.Errors.Count > 0)
            {
                throw new CompilationException(compileResult);
            }

            GeneratedAssemblyInfo result = new GeneratedAssemblyInfo(FilePath, compileResult);

            result.Save();
            return(result);
        }
コード例 #2
0
        public GeneratedAssemblyInfo GenerateAssembly()
        {
            Args.ThrowIfNullOrEmpty(AssemblyName, nameof(AssemblyName));

            GeneratedAssemblyInfo result = null;
            AutoResetEvent        wait   = new AutoResetEvent(false);

            GenerateCsFiles(Types, (o, a) =>
            {
                CompilerResults compilerResults = AdHocCSharpCompiler.CompileDirectory(new DirectoryInfo(CsFileDirectory), AssemblyName, new Assembly[] { typeof(IMessage).Assembly });
                result = new GeneratedAssemblyInfo(AssemblyName, compilerResults);
                wait.Set();
            });
            wait.WaitOne();
            return(result);
        }