Ejemplo n.º 1
0
        private void ProcessFiles(IEnumerable <string> files, string description, Func <string, string> processor)
        {
            var cfg = Configuration;

            foreach (var file in files)
            {
                if (file == null)
                {
                    continue;
                }
                try {
                    string fileName = Path.Combine(Path.GetDirectoryName(cfg.SourcePath), file);
                    string text     = LoadFile(fileName, description, "  ", true);
                    if (text.IsNullOrEmpty())
                    {
                        Console.WriteLine("    File is empty or does not exist.");
                        continue;
                    }
                    Console.Write("    Processing...");
                    try {
                        text = processor.Invoke(text);
                    }
                    catch {
                        Console.WriteLine();
                        throw;
                    }
                    Console.WriteLine(" Done.");
                    SaveFile(fileName, description, text, "  ");
                } catch (Exception error) {
                    ErrorReporter.Report(error);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Notify that an assertion has failed.
        /// </summary>
        /// <param name="text">Bug report</param>
        /// <param name="killTasks">Kill tasks</param>
        internal void NotifyAssertionFailure(string text, bool killTasks = true)
        {
            if (!this.BugFound)
            {
                this.BugReport = text;

                ErrorReporter.Report(text);

                IO.Log("<StrategyLog> Found bug using " +
                       $"'{this.Runtime.Configuration.SchedulingStrategy}' strategy.");

                if (this.Strategy.GetDescription().Length > 0)
                {
                    IO.Log($"<StrategyLog> {this.Strategy.GetDescription()}");
                }

                this.BugFound = true;

                if (this.Runtime.Configuration.AttachDebugger)
                {
                    System.Diagnostics.Debugger.Break();
                }
            }

            if (killTasks)
            {
                this.Stop();
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Determines if this card box was clicked on.
 /// </summary>
 /// <param name="Click"></param>
 /// <returns></returns>
 public bool WasIClicked(Point Click)
 {
     try
     {
         if (this.Visible)
         {
             if (Click.X >= this.Location.X && Click.X <= this.Location.X + this.Size.Width)
             {
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
         else
         {
             return(false);
         }
     }
     catch (Exception TheException)
     {
         ErrorReporter.Report(TheException);
         return(true);
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Adds all of the cards into the deck.
        /// </summary>
        /// <param name="WithJokers"></param>
        public void AddCards(bool WithJokers)
        {
            try
            {
                int i = 1;
                int stop;

                if (WithJokers)
                {
                    stop = 55;
                }
                else
                {
                    stop = 53;
                }

                while (i != stop)
                {
                    Cards.Add(new Card(i));
                    i++;
                }
            }
            catch (Exception TheException)
            {
                ErrorReporter.Report(TheException);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// The constructor for the Deck class. This automatically shuffles the deck. Also adds multiple decks if DecksToAdd is greater than 1.
        /// </summary>
        public Deck(bool WithJokers, int DecksToAdd)
        {
            try
            {
                Cards = new List <Card>();

                if (DecksToAdd > 1)
                {
                    int i = 0;

                    while (i != DecksToAdd)
                    {
                        this.AddCards(WithJokers);
                        i++;
                    }
                }
                else
                {
                    this.AddCards(WithJokers);
                }
                this.Shuffle();
            }
            catch (Exception TheException)
            {
                ErrorReporter.Report(TheException);
            }
        }
Ejemplo n.º 6
0
		static int Main(string[] args)
		{
			CommandLineParser parser = new CommandLineParser( args );

			if (parser.RegistrationPath.Length == 0)
					parser.RegistrationPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetAssembly(typeof(RegistrarApp)).Location);

			try
			{
				AssemblyRegistrar registrar = new AssemblyRegistrar( parser );

				if( parser.RegisterMode == CommandLineParser.InstallMode.Register )
					registrar.Register();
				else
				{
					try
					{
						registrar.UnRegister();
					}
					catch
					{
						// ignore the exception
					}
				}
				return (int) ReturnValue.Success;
			}
			catch( Exception ex )
			{
				System.Diagnostics.Debug.Assert(false, ex.Message);
				ErrorReporter reporter = new ErrorReporter(parser.RegistrationPath, parser.SilentMode);
				reporter.Report(ex.Message);
				return (int) ReturnValue.Failure;
			}
		}
Ejemplo n.º 7
0
        private async void MainWindow_Loaded(object sender, System.Windows.RoutedEventArgs e)
        {
            try
            {
                var path = GetGridLayoutPath();

                if (File.Exists(path))
                {
                    dataGrid.RestoreLayoutFromXml(path);
                }

                path = GetLayoutPath();

                if (File.Exists(path))
                {
                    layout.RestoreLayoutFromXml(path);
                }

                await _model.CheckForFile();
            }
            catch (Exception ex)
            {
                ErrorReporter.Report(_log, ex);
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Determines which resources to load based on the size of everything.
        /// </summary>
        public static void LoadResources()
        {
            try
            {
                Size ScreenSize = Util.GetScreenSize(VariableStorage.TheForm);

                if (ScreenSize.Height > 1440)
                {
                    LoadResourcesHighestRes();
                    return;
                }

                if (ScreenSize.Height <= 1440 && ScreenSize.Height > 1200)
                {
                    LoadResources960x1440();
                    return;
                }

                if (ScreenSize.Height <= 1200)
                {
                    LoadResources870x1200();
                    return;
                }
            }
            catch (Exception TheException)
            {
                ErrorReporter.Report(TheException);
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Finds the custom rewriting passes with the specified attribute.
        /// Returns null if no such method is found.
        /// </summary>
        /// <param name="assembly">Assembly</param>
        /// <param name="attribute">Type</param>
        /// <returns>Types</returns>
        private List <Type> FindCustomRewritingPasses(Assembly assembly, Type attribute)
        {
            List <Type> passes = null;

            try
            {
                passes = assembly.GetTypes().Where(m => m.GetCustomAttributes(attribute, false).Length > 0).ToList();
            }
            catch (ReflectionTypeLoadException ex)
            {
                foreach (var le in ex.LoaderExceptions)
                {
                    ErrorReporter.Report(le.Message);
                }

                IO.Error.ReportAndExit($"Failed to load assembly '{assembly.FullName}'");
            }
            catch (Exception ex)
            {
                ErrorReporter.Report(ex.Message);
                IO.Error.ReportAndExit($"Failed to load assembly '{assembly.FullName}'");
            }

            return(passes);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Reports the parsing errors and exits. Only works if the
        /// parser is running internally.
        /// </summary>
        private void ReportParsingErrors()
        {
            if (!base.Options.ExitOnError)
            {
                return;
            }

            foreach (var error in this.ErrorLog)
            {
                var report    = error.Item2;
                var errorLine = base.SyntaxTree.GetLineSpan(error.Item1.Span).StartLinePosition.Line + 1;

                var root  = base.SyntaxTree.GetRoot();
                var lines = System.Text.RegularExpressions.Regex.Split(root.ToFullString(), "\r\n|\r|\n");

                report += "\nIn " + this.SyntaxTree.FilePath + " (line " + errorLine + "):\n";
                report += " " + lines[errorLine - 1];

                ErrorReporter.Report(report);
            }

            IO.PrettyPrintLine("Found {0} parsing error{1}.", this.ErrorLog.Count,
                               this.ErrorLog.Count == 1 ? "" : "s");
            Environment.Exit(1);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Creates a GolfPlayer object, and returns it.
        /// </summary>
        /// <param name="IsAI"></param>
        private GolfPlayer DealInPlayer(bool IsAI)
        {
            try
            {
                GolfPlayer Player;
                Card[]     Cards = new Card[6];

                int i = 0;

                while (i != 6)
                {
                    Cards[i] = this.TheDeck.GetTop();
                    i++;
                }

                Player = new GolfPlayer(Cards, IsAI);

                return(Player);
            }
            catch (Exception TheException)
            {
                ErrorReporter.Report(TheException);
                return(null);
            }
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Finds the test methods with the specified attribute.
        /// Returns an empty list if no such methods are found.
        /// </summary>
        /// <param name="attribute">Type</param>
        /// <returns>MethodInfos</returns>
        private List <MethodInfo> FindTestMethodsWithAttribute(Type attribute)
        {
            List <MethodInfo> testMethods = null;

            try
            {
                testMethods = this.Assembly.GetTypes().SelectMany(t => t.GetMethods(BindingFlags.Static |
                                                                                    BindingFlags.Public | BindingFlags.DeclaredOnly | BindingFlags.InvokeMethod)).
                              Where(m => m.GetCustomAttributes(attribute, false).Length > 0).ToList();
            }
            catch (ReflectionTypeLoadException ex)
            {
                foreach (var le in ex.LoaderExceptions)
                {
                    ErrorReporter.Report(le.Message);
                }

                IO.Error.ReportAndExit($"Failed to load assembly '{this.Assembly.FullName}'");
            }
            catch (Exception ex)
            {
                ErrorReporter.Report(ex.Message);
                IO.Error.ReportAndExit($"Failed to load assembly '{this.Assembly.FullName}'");
            }

            return(testMethods);
        }
Ejemplo n.º 13
0
 public void Check(Page page, ErrorReporter reporter)
 {
     if (!TitleCasing.IsCamelCase(page.Title))
     {
         reporter.Report(page, "Page title is not camel case");
     }
 }
Ejemplo n.º 14
0
        public DialogResult ShowDialog(IWin32Window owner)
        {
            var isLogicError = !IsID10TError(_exception);

            var editReportLinkHref = "edit_report";

            var dialog = new TaskDialog
            {
                Cancelable        = true,
                DetailsExpanded   = false,
                HyperlinksEnabled = true,
                ExpansionMode     = TaskDialogExpandedDetailsLocation.ExpandFooter,
                StartupLocation   = TaskDialogStartupLocation.CenterOwner,

                Icon                = TaskDialogStandardIcon.Error,
                Caption             = _title,
                InstructionText     = "An unexpected error occured.",
                Text                = _exception.Message,
                DetailsExpandedText = _exception.ToString(),

                DetailsCollapsedLabel = "Show &details",
                DetailsExpandedLabel  = "Hide &details",

                FooterText = string.Format("<a href=\"{0}\">Edit report contents</a>", editReportLinkHref),

                OwnerWindowHandle = owner.Handle
            };

            var sendButton = new TaskDialogCommandLink("sendButton", "&Report This Error\nFast and painless - I promise!");

            sendButton.Click += delegate
            {
                new TaskBuilder()
                .OnCurrentThread()
                .DoWork((invoker, token) => ErrorReporter.Report(_exception))
                .Fail(args => ReportExceptionFail(owner, args))
                .Succeed(() => ReportExceptionSucceed(owner))
                .Build()
                .Start();
                dialog.Close(TaskDialogResult.Yes);
            };

            var dontSendButton = new TaskDialogCommandLink("dontSendButton", "&No Thanks\nI don't feel like being helpful");

            dontSendButton.Click += delegate
            {
                dialog.Close(TaskDialogResult.No);
            };

            dialog.HyperlinkClick += (sender, args) => MessageBox.Show(owner, args.LinkText);

            if (true || isLogicError)
            {
                dialog.Controls.Add(sendButton);
                dialog.Controls.Add(dontSendButton);
            }

            return(dialog.Show().ToDialogResult());
        }
Ejemplo n.º 15
0
 public void Report()
 {
     ExceptionForm form = new ExceptionForm(message, ex);
     if (form.ShowDialog(owner) == DialogResult.OK) {
         ErrorReporter reporter = new ErrorReporter();
         reporter.Report(ex);
     }
 }
Ejemplo n.º 16
0
 /// <summary>
 /// Checks if the assertion holds, and if not it reports
 /// an error and exits.
 /// </summary>
 /// <param name="predicate">Predicate</param>
 public static void Assert(bool predicate)
 {
     if (!predicate)
     {
         ErrorReporter.Report("Assertion failure.");
         Environment.Exit(1);
     }
 }
Ejemplo n.º 17
0
 /// <summary>
 /// Checks if the assertion holds, and if not it reports
 /// an error and exits.
 /// </summary>
 /// <param name="predicate">Predicate</param>
 /// <param name="s">Message</param>
 /// <param name="args">Message arguments</param>
 public static void Assert(bool predicate, string s, params object[] args)
 {
     if (!predicate)
     {
         string message = Output.Format(s, args);
         ErrorReporter.Report(message);
         Environment.Exit(1);
     }
 }
Ejemplo n.º 18
0
 private void newToolStripMenuItem6_Click(object sender, EventArgs e)
 {
     try
     {
     }
     catch (Exception TheException)
     {
         ErrorReporter.Report(TheException);
     }
 }
Ejemplo n.º 19
0
        public void Report()
        {
            ExceptionForm form = new ExceptionForm(message, ex);

            if (form.ShowDialog(owner) == DialogResult.OK)
            {
                ErrorReporter reporter = new ErrorReporter();
                reporter.Report(ex);
            }
        }
Ejemplo n.º 20
0
 /// <summary>
 /// Kicked off on startup to launch various processes.
 /// </summary>
 public static void DoMaintinence()
 {
     try
     {
         VerifyFoldersForChildModules();
     }
     catch (Exception TheException)
     {
         ErrorReporter.Report(TheException);
     }
 }
Ejemplo n.º 21
0
 private void NewGolfForm_Load(object sender, EventArgs e)
 {
     try
     {
         this.AICountTBox.Text = Golf.Properties.Settings.Default.GolfAIPlayers.ToString();
     }
     catch (Exception TheException)
     {
         ErrorReporter.Report(TheException);
     }
 }
Ejemplo n.º 22
0
 /// <summary>
 /// The initial call to this program.
 /// </summary>
 public Form1()
 {
     try
     {
         InitializeComponent();
     }
     catch (Exception TheException)
     {
         ErrorReporter.Report(TheException);
     }
 }
Ejemplo n.º 23
0
 /// <summary>
 /// Shuffles the deck.
 /// </summary>
 public void Shuffle()
 {
     try
     {
         this.Cards = Util.Randomize <Card>(Cards);
     }
     catch (Exception TheException)
     {
         ErrorReporter.Report(TheException);
     }
 }
Ejemplo n.º 24
0
 /// <summary>
 /// This is called when the form loads.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Form1_Load(object sender, EventArgs e)
 {
     try
     {
         main.Startup();
     }
     catch (Exception TheException)
     {
         ErrorReporter.Report(TheException);
     }
 }
Ejemplo n.º 25
0
 /// <summary>
 /// Launches a menu that allows the user to save the current game.
 /// </summary>
 public void Save()
 {
     try
     {
         Util.SerializeObjectToFile(Filing.GolfSaveFolderPath + "\\" + this.CurrentGameSaveName, this);
     }
     catch (Exception TheException)
     {
         ErrorReporter.Report(TheException);
     }
 }
Ejemplo n.º 26
0
 private void loadToolStripMenuItem5_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e)
 {
     try
     {
         this.main.StopCardGame();
     }
     catch (Exception TheException)
     {
         ErrorReporter.Report(TheException);
     }
 }
Ejemplo n.º 27
0
 private void saveToolStripMenuItem5_Click(object sender, EventArgs e)
 {
     try
     {
         this.main.Current.Save();
     }
     catch (Exception TheException)
     {
         ErrorReporter.Report(TheException);
     }
 }
Ejemplo n.º 28
0
 /// <summary>
 /// Launches a menu that allows the user to specify what to load.
 /// </summary>
 public void Load(string GameName)
 {
     try
     {
         Util.ReadSerializedObjectFromFile(Filing.GolfSaveFolderPath + "\\" + GameName);
     }
     catch (Exception TheException)
     {
         ErrorReporter.Report(TheException);
     }
 }
Ejemplo n.º 29
0
 private void golfToolStripMenuItem2_Click(object sender, EventArgs e)
 {
     try
     {
         this.main.StartNewCardGame(new GolfLogic());
     }
     catch (Exception TheException)
     {
         ErrorReporter.Report(TheException);
     }
 }
Ejemplo n.º 30
0
 public void TestThrowsWin32Exception()
 {
     try
     {
         throw new WebException("Blah blah blah");
     }
     catch (Exception e)
     {
         ErrorReporter.Report(e);
     }
 }
Ejemplo n.º 31
0
 /// <summary>
 /// Serializes this object to XML.
 /// </summary>
 /// <param name="info"></param>
 /// <param name="context"></param>
 public void GetObjectData(SerializationInfo info, StreamingContext context)
 {
     try
     {
         info.AddValue("GolfPlayers", this.Players);
     }
     catch (Exception TheException)
     {
         ErrorReporter.Report(TheException);
     }
 }
Ejemplo n.º 32
0
 /// <summary>
 /// Called when we want to shut this program down.
 /// </summary>
 public void Shutdown(int Code)
 {
     try
     {
         Environment.Exit(Code);
     }
     catch (Exception TheException)
     {
         ErrorReporter.Report(TheException);
     }
 }
Ejemplo n.º 33
0
		private void ReportError(string message)
		{
			ErrorReporter reporter = new ErrorReporter(m_parser.RegistrationPath, m_parser.SilentMode);
			reporter.Report(message);
		}
Ejemplo n.º 34
0
        private void ImportFilesInComponent(TreeNode node, XmlNode componentNode, string[] files)
        {
            if (componentNode.Name == "Component")
            {
                bool mustExpand = (node.Nodes.Count == 0);

                CurrentTreeView.SuspendLayout();

                bool foundReg = false;
                foreach (string file in files)
                {
                    if (Path.GetExtension(file).ToLower() == ".reg")
                    {
                        foundReg = true;
                        break;
                    }
                }

                bool importRegistryFiles = false;
                if (foundReg == true)
                {
                    DialogResult result = MessageBox.Show(this, "Import Registry (*.reg) files to Registry elements?", "Import?", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                    if (result == DialogResult.Cancel)
                    {
                        return;
                    }
                    else if (result == DialogResult.Yes)
                    {
                        importRegistryFiles = true;
                    }
                }

                WixFiles.UndoManager.BeginNewCommandRange();
                StringBuilder errorMessageBuilder = new StringBuilder();

                foreach (string file in files)
                {
                    FileInfo fileInfo = new FileInfo(file);
                    try
                    {
                        if (fileInfo.Extension.ToLower() == ".reg" && importRegistryFiles)
                        {
                            RegistryImport regImport = new RegistryImport(WixFiles, fileInfo, componentNode);
                            regImport.Import(node);
                        }
                        else
                        {
                            FileImport fileImport = new FileImport(WixFiles, fileInfo, componentNode);
                            fileImport.Import(node);
                        }
                    }
                    catch (WixEditException ex)
                    {
                        errorMessageBuilder.AppendFormat("{0} ({1})\r\n", fileInfo.Name, ex.Message);
                    }
                    catch (Exception ex)
                    {
                        string message = String.Format("An exception occured during the import of \"{0}\"! Please press OK to report this error to the WixEdit website, so this error can be fixed.", fileInfo.Name);
                        ExceptionForm form = new ExceptionForm(message, ex);
                        if (form.ShowDialog() == DialogResult.OK)
                        {
                            ErrorReporter reporter = new ErrorReporter();
                            reporter.Report(ex);
                        }
                    }
                }

                if (errorMessageBuilder.Length > 0)
                {
                    MessageBox.Show(this, "Import failed for the following files:\r\n\r\n" + errorMessageBuilder.ToString(), "Import failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                ShowNode(componentNode);

                if (mustExpand)
                {
                    node.Expand();
                }

                CurrentTreeView.ResumeLayout();
            }
        }