Пример #1
0
        static int Main(string[] args)
        {
            if (args.Length == 0)
            {
                ShowHelp();
                return(0);
            }

            bool verboise = false;

            for (int i = 0; i < args.Length; i++)
            {
                switch (args[i])
                {
                case "--version":
                case "/version":
                    ShowVersion();
                    return(0);

                case "--help":
                case "/?":
                case "/help":
                    ShowHelp();
                    return(0);

                case "/V":
                case "-V":
                    verboise = true;
                    break;

                default:
                    filepath = args[i];
                    break;
                }
            }

            try
            {
                // Interpreter already checks if the file exists
                ErrorCode r = Interpreter.Run(filepath, verboise);

                if (r != ErrorCode.Success)
                {
                    WriteLine($"ERROR: {r} - {r.GetErrorMessage()} ({r.Hex()})");
                }

                return(r.ToInt());
            }
            catch (Exception ex)
            {
                ForegroundColor = ConsoleColor.Red;
                WriteLine("[ ERROR ]");
                ResetColor();
                WriteLine($"Exception: {ex.GetType()} - 0x{ex.HResult:X8}");
                WriteLine($"  Message: {ex.Message}");
                return(ex.HResult);
            }
        }
Пример #2
0
        void RunFile()
        {
            txtDebuggerOutput.Clear();
            ErrorCode r = Interpreter.Run(CurrentFile.FullName, true);

            if (r != ErrorCode.Success)
            {
                txtDebuggerOutput.AppendText($"Return code: {r} ({r.Hex()})\n");
                txtDebuggerOutput.AppendText($"Message: {r.GetErrorMessage()}");
            }
        }
Пример #3
0
 void CheckReturnValue(int rc)
 {
     try
     {
         if (rc != 0)
         {
             throw new Exception(ErrorCode.GetErrorMessage(rc));
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Пример #4
0
        static int Main(string[] args)
        {
            int len = args.Length;

            // No arguments
            if (len == 0)
            {
                ShowForm();
                return(0);
            }

            string file = args[len - 1];

            if (len > 1)
            {
                for (int i = 0; i < len; i++)
                {
                    switch (args[i])
                    {
                    case "/debug":
                        ShowForm(file);
                        return(0);
                    }
                }
            }

            ErrorCode err = Run(file);

            if (err != ErrorCode.Success)
            {
                Application.EnableVisualStyles();
                MessageBox.Show($"{err}\n\r{err.GetErrorMessage()} (0x{err:X4})",
                                $"WinYourDesktop - {err}",
                                MessageBoxButtons.OK);
            }

            return(err.ToInt());
        }
 /// <summary>
 /// Adds an error code and message to the validation step.
 /// </summary>
 /// <param name="IRuleBuilderOptions<TEntity"></param>
 /// <param name="rule"></param>
 /// <param name="errorCode">The error code to use for the validation step.</param>
 /// <param name="propertyName">The property being validated - user friendly name for displaying in error message.</param>
 /// <typeparam name="TEntity"></typeparam>
 /// <typeparam name="TProperty"></typeparam>
 /// <returns></returns>
 public static IRuleBuilderOptions <TEntity, TProperty> AddError <TEntity, TProperty>(this IRuleBuilderOptions <TEntity, TProperty> rule,
                                                                                      ErrorCode errorCode, string propertyName = null)
 => rule
 .WithErrorCode(errorCode.GetErrorCodeString())
 .WithMessage(errorCode.GetErrorMessage(propertyName));