示例#1
0
        public LiveViewHost(ILiveView view, Action <string> logger)
        {
            _logger          = logger;
            _sourceWatcher   = new LiveSourceWatcher(logger);
            _assemblyWatcher = new LiveFileWatcher(logger);
            _assemblyPath    = view.GetType().Assembly.Location;

            var loader = new LiveControlLoader(logger);

            _subscription = _assemblyWatcher
                            .FileChanged
                            .ObserveOn(AvaloniaScheduler.Instance)
                            .Select(path => loader.LoadControl(path, this))
                            .Subscribe(control => Content = control);

            AppDomain.CurrentDomain.ProcessExit += (sender, args) =>
            {
                Dispose();
                Process.GetCurrentProcess().Kill();
            };

            Console.CancelKeyPress += (sender, args) =>
            {
                Dispose();
                Process.GetCurrentProcess().Kill();
            };
        }
示例#2
0
        public LiveViewHost(ILiveView view, Action <string> logger)
        {
            _logger          = logger;
            _sourceWatcher   = new LiveSourceWatcher(logger);
            _assemblyWatcher = new LiveFileWatcher(logger);
            _assemblyPath    = view.GetType().Assembly.Location;

            var loader = new LiveControlLoader(logger);

            _subscription = _assemblyWatcher
                            .FileChanged
                            .ObserveOn(AvaloniaScheduler.Instance)
                            .Subscribe(path => loader.LoadControl(path, this));

            Console.CancelKeyPress += (sender, args) => Clean("Console Ctrl+C key press.", false);
            AppDomain.CurrentDomain.ProcessExit        += (sender, args) => Clean("Process termination.", false);
            AppDomain.CurrentDomain.UnhandledException += (sender, args) => Clean(args.ExceptionObject.ToString(), true);
        }