Exemplo n.º 1
0
        protected void ShowDiff(int index1, int index2)
        {
            var viewer = new DiffViewer(Scheduler, Instance);

            viewer.Start(viewer.LoadRange(Pair.New(index1, index2)));

            viewer.Show(this);
        }
Exemplo n.º 2
0
        public static IEnumerator <object> OpenFilenames(IEnumerable <string> filenames, MainWindow mainWindow = null)
        {
            var    diffs     = new HashSet <string>();
            var    snapshots = new HashSet <string>();
            string recording = null;

            foreach (var filename in filenames)
            {
                switch (Path.GetExtension(filename))
                {
                case ".heaprecording": {
                    if (recording != null)
                    {
                        MessageBox.Show("Only one heap recording can be opened at a time.", "Error");
                        continue;
                    }
                    else if (snapshots.Count > 0)
                    {
                        MessageBox.Show("You cannot open snapshots and a recording in the same session.", "Error");
                        continue;
                    }

                    recording = filename;
                } break;

                case ".heapsnap": {
                    if (recording != null)
                    {
                        MessageBox.Show("You cannot open snapshots and a recording in the same session.", "Error");
                        continue;
                    }

                    snapshots.Add(filename);
                } break;

                case ".heapdiff": {
                    diffs.Add(filename);
                } break;
                }
            }

            var futures     = new OwnedFutureSet();
            var disposables = new HashSet <IDisposable>();

            if ((recording != null) || (snapshots.Count > 0))
            {
                if (mainWindow == null)
                {
                    mainWindow = new MainWindow(Scheduler);
                    disposables.Add(mainWindow);
                    futures.Add(mainWindow.Show());
                }

                if (recording != null)
                {
                    mainWindow.OpenRecording(recording);
                }
                else
                {
                    mainWindow.OpenSnapshots(snapshots);
                }
            }

            foreach (var diff in diffs)
            {
                var viewer = new DiffViewer(Scheduler);
                disposables.Add(viewer);

                if (mainWindow != null)
                {
                    futures.Add(viewer.Show(mainWindow));
                }
                else
                {
                    futures.Add(viewer.Show());
                }

                yield return(viewer.LoadDiff(diff));
            }

            if (futures.Count == 0)
            {
                if ((mainWindow == null) && (disposables.Count > 0))
                {
                    throw new InvalidDataException();
                }
            }
            else
            {
                using (futures)
                    try {
                        yield return(Future.WaitForAll(futures));
                    } finally {
                        foreach (var disposable in disposables)
                        {
                            disposable.Dispose();
                        }
                    }
            }
        }
Exemplo n.º 3
0
        public static IEnumerator<object> OpenFilenames(IEnumerable<string> filenames, MainWindow mainWindow = null)
        {
            var diffs = new HashSet<string>();
            var snapshots = new HashSet<string>();
            string recording = null;

            foreach (var filename in filenames) {
                switch (Path.GetExtension(filename)) {
                    case ".heaprecording": {
                        if (recording != null) {
                            MessageBox.Show("Only one heap recording can be opened at a time.", "Error");
                            continue;
                        } else if (snapshots.Count > 0) {
                            MessageBox.Show("You cannot open snapshots and a recording in the same session.", "Error");
                            continue;
                        }

                        recording = filename;
                    } break;
                    case ".heapsnap": {
                        if (recording != null) {
                            MessageBox.Show("You cannot open snapshots and a recording in the same session.", "Error");
                            continue;
                        }

                        snapshots.Add(filename);
                    } break;
                    case ".heapdiff": {
                        diffs.Add(filename);
                    } break;
                }
            }

            var futures = new OwnedFutureSet();
            var disposables = new HashSet<IDisposable>();

            if ((recording != null) || (snapshots.Count > 0)) {
                if (mainWindow == null) {
                    mainWindow = new MainWindow(Scheduler);
                    disposables.Add(mainWindow);
                    futures.Add(mainWindow.Show());
                }

                if (recording != null)
                    mainWindow.OpenRecording(recording);
                else
                    mainWindow.OpenSnapshots(snapshots);
            }

            foreach (var diff in diffs) {
                var viewer = new DiffViewer(Scheduler);
                disposables.Add(viewer);

                if (mainWindow != null)
                    futures.Add(viewer.Show(mainWindow));
                else
                    futures.Add(viewer.Show());

                yield return viewer.LoadDiff(diff);
            }

            if (futures.Count == 0) {
                if ((mainWindow == null) && (disposables.Count > 0))
                    throw new InvalidDataException();
            } else {
                using (futures)
                try {
                    yield return Future.WaitForAll(futures);
                } finally {
                    foreach (var disposable in disposables)
                        disposable.Dispose();
                }
            }
        }
Exemplo n.º 4
0
        protected void ShowDiff(int index1, int index2)
        {
            var viewer = new DiffViewer(Scheduler, Instance);

            viewer.Start(viewer.LoadRange(Pair.New(index1, index2)));

            viewer.Show(this);
        }