Exemplo n.º 1
0
        static int Main(string[] args)
        {
            var interpreter = new CommandLineInterpreter();
            var msgHelper = new ConsoleMessageHelper();

            List<string> xamls = new List<string>();

            if (!interpreter.Parse(args))
            {
                msgHelper.AddMessage("Usage: SnoopBCConsole RootPath [ignoreControl1] [ignoreControl2] [ignoreControl3] [...]");
                return 1;
            }
            else
            {

                var processor = new XamlFilesProcessor();

                xamls = processor.FindFiles(interpreter.Path,
                    (s, s1) => msgHelper.AddMessage(s + ": " + s1), msgHelper);

                if (xamls.Count == 0)
                {
                    msgHelper.AddMessage("No Xaml files found");
                    return 2;
                }
                else
                {
                    var exceptions = processor.ProcessXamls(xamls,
                        (s, s1) => msgHelper.AddMessage(s + ": " + s1), i => { },
                        msgHelper, interpreter.Ignores);

                    if (exceptions > 0)
                    {
                        msgHelper.AddMessage("Exception count: " + exceptions);
                        return 3;
                    }
                }
            }

            msgHelper.AddMessage(string.Format(
                "Successfully added breadcrumbs to {0} files.", xamls.Count));

            return 0;
        }
Exemplo n.º 2
0
        public void ProcessXamls()
        {
            this.AsyncProcessing = true;
            this.FilesProcessed = 0;

            int exceptionCount = 0;

            DisplayText = string.Empty;

            var task = Task.Factory.StartNew(
                () =>
                {
                    try
                    {
                        var processor = new XamlFilesProcessor();

                        var xamls = processor.FindFiles(this.RootFolder,
                            ShowErrMsgBox, this);

                        this.TotalFilesToProcess = xamls.Count;

                        exceptionCount += processor.ProcessXamls(xamls,
                            ShowErrMsgBox, i => this.FilesProcessed = i, this,
                            this.SelectedItems.Cast<string>());

                    }
                    catch (Exception ex)
                    {
                        exceptionCount++;
                        AddMessage("Exception: " + ex.ToString());
                    }
                }
                );

            task.ContinueWith(obj =>
            {

                AsyncProcessing = false;

                //TODO:  note skipped files count
                this.AddMessage(string.Format("Finished. Files Processed: {0}.  Excptions {1}.", this.FilesProcessed, exceptionCount));
            }
                );
        }