public Assembly GetAssembly()
        {
            if (Compiler.AssemblyName == default)
            {
                Compiler.AssemblyName = Guid.NewGuid().ToString("N");
            }


            //如果是文件编译,则初始化路径
            if (Compiler.AssemblyOutputKind == Framework.AssemblyBuildKind.File)
            {
                if (OutputFolder == GlobalOutputFolder)
                {
                    OutputFolder = Path.Combine(GlobalOutputFolder, Compiler.Domain.Name);
                }
                if (!Directory.Exists(OutputFolder))
                {
                    Directory.CreateDirectory(OutputFolder);
                }
                if (Compiler.DllPath == default)
                {
                    Compiler.DllPath = Path.Combine(OutputFolder, Compiler.AssemblyName + ".dll");
                    Compiler.PdbPath = Path.Combine(OutputFolder, Compiler.AssemblyName + ".pdb");
                }
            }


            //进入编译流程
            Compile();


            //如果编译出错
            if (Compiler.Assembly == null && Exceptions != null && Exceptions.Count > 0)
            {
                switch (Compiler.ErrorBehavior)
                {
                case ExceptionBehavior.Log | ExceptionBehavior.Throw:
                    LogOperator.ErrorRecoder(Compiler.Compilation, Exceptions);
                    throw Exceptions[0];

                case ExceptionBehavior.Log:
                    LogOperator.ErrorRecoder(Compiler.Compilation, Exceptions);
                    break;

                case ExceptionBehavior.Throw:
                    throw Exceptions[0];

                default:
                    break;
                }
            }
            else
            {
                LogOperator.SucceedRecoder(Compiler.Compilation);
            }
            return(Compiler.Assembly);
        }
 /// <summary>
 /// 错误处理
 /// </summary>
 /// <param name="exception"></param>
 private void HandlerErrors(NatashaException exception)
 {
     if (SyntaxErrorBehavior == ExceptionBehavior.Throw)
     {
         throw exception;
     }
     else if (SyntaxErrorBehavior == ExceptionBehavior.Log)
     {
         LogOperator.ErrorRecoder(exception);
     }
     else if (SyntaxErrorBehavior == (ExceptionBehavior.Log | ExceptionBehavior.Throw))
     {
         LogOperator.ErrorRecoder(exception);
         throw exception;
     }
 }
 private void HandlerErrors(CompilationException exception)
 {
     if (ErrorBehavior == ExceptionBehavior.Throw)
     {
         throw exception;
     }
     else if (ErrorBehavior == ExceptionBehavior.Log)
     {
         LogOperator.ErrorRecoder(exception);
     }
     else if (ErrorBehavior == (ExceptionBehavior.Log | ExceptionBehavior.Throw))
     {
         LogOperator.ErrorRecoder(exception);
         throw exception;
     }
 }
Example #4
0
        public Assembly GetAssembly()
        {
            //如果是文件编译,则初始化路径
            if (Compiler.AssemblyOutputKind == Framework.AssemblyBuildKind.File)
            {
                if (Compiler.DllPath == default)
                {
                    Compiler.DllPath = Path.Combine(OutputFolder, Compiler.AssemblyName, ".dll");
                    Compiler.PdbPath = Path.Combine(OutputFolder, Compiler.AssemblyName, ".pdb");
                }
            }


            //进入编译流程
            Compile();


            //如果编译出错
            if (Compiler.Assembly == null && Exceptions != null && Exceptions.Count > 0)
            {
                switch (Compiler.ErrorBehavior)
                {
                case ExceptionBehavior.Log | ExceptionBehavior.Throw:
                    LogOperator.ErrorRecoder(Compiler.Compilation, Exceptions);
                    throw Exceptions[0];

                case ExceptionBehavior.Log:
                    LogOperator.ErrorRecoder(Compiler.Compilation, Exceptions);
                    break;

                case ExceptionBehavior.Throw:
                    throw Exceptions[0];

                default:
                    break;
                }
            }
            else
            {
                LogOperator.SucceedRecoder(Compiler.Compilation);
            }
            return(Compiler.Assembly);
        }