/// <summary>
        ///
        /// </summary>
        /// <param name="path"></param>
        /// <param name="lines"></param>
        /// <remarks>
        /// Constructor arguments are passed by <see cref="ServiceProviderExtension.CreateSourceFileViewModel"/>.
        /// It is mandatory that they are in sync.
        /// </remarks>
        public SourceFileViewModel(IViceBridge viceBridge, AcmeFile file, ImmutableArray <LineViewModel> lines, BreakpointsViewModel breakpoints)
        {
            this.viceBridge              = viceBridge;
            this.breakpoints             = breakpoints;
            this.file                    = file;
            uiFactory                    = new TaskFactory(TaskScheduler.FromCurrentSynchronizationContext());
            Lines                        = lines;
            viceBridge.ConnectedChanged += ViceBridge_ConnectedChanged;
            AddOrRemoveBreakpointCommand = new RelayCommandAsync <LineViewModel>(AddOrRemoveBreakpointAsync,
                                                                                 canExecute: l => l?.Address is not null && viceBridge.IsConnected);
            var fileBreakpoints = breakpoints.Breakpoints.Where(b => b.File == file).ToImmutableArray();

            AddBreakpointsToLine(fileBreakpoints);
            breakpoints.Breakpoints.CollectionChanged += Breakpoints_CollectionChanged;
        }
예제 #2
0
        public static SourceFileViewModel CreateScopedSourceFileViewModel(this IServiceProvider serviceProvider, AcmeFile file, ImmutableArray <LineViewModel> lines)
        {
            var contentScope = serviceProvider.CreateScope();
            var viewModel    = ActivatorUtilities.CreateInstance <SourceFileViewModel>(serviceProvider, file, lines);

            viewModel.AssignScope(contentScope);
            return(viewModel);
        }