<commit_before>﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Composition;
using System.ComponentModel.Composition.Primitives;
using System.IO;
using System.Linq;
using System.Threading;
using System.Windows;
using System.Xml.Serialization;
using BCad.Collections;
using BCad.Commands;
using BCad.Entities;
using BCad.EventArguments;
using BCad.FileHandlers;
using BCad.Services;

namespace BCad
{
    [Export(typeof(IWorkspace))]
    internal class Workspace : IWorkspace
    {
        public Workspace()
        {
            LoadSettings(ConfigFile);
        }

        #region Events

        public event CommandExecutingEventHandler CommandExecuting;

        protected virtual void OnCommandExecuting(CommandExecutingEventArgs e)
        {
            if (CommandExecuting != null)
                CommandExecuting(this, e);
        }

        public event CommandExecutedEventHandler CommandExecuted;

        protected virtual void OnCommandExecuted(CommandExecutedEventArgs e)
        {
            if (CommandExecuted != null)
                CommandExecuted(this, e);
        }

        #endregion

        #region Properties

        private Drawing drawing = new Drawing();
        public Drawing Drawing
        {
            get { return drawing; }
        }

        private Plane drawingPlane = new Plane(Point.Origin, Vector.ZAxis);
        public Plane DrawingPlane
        {
            get { return drawingPlane; }
        }

        private ObservableHashSet<Entity> selectedEntities = new ObservableHashSet<Entity>();
        public ObservableHashSet<Entity> SelectedEntities
        {
            get { return selectedEntities; }
        }

        #endregion

        #region Imports

        [Import]
        private IInputService InputService = null;

        // required so that the service is created before the undo or redo commands are fired
        [Import]
        private IUndoRedoService UndoRedoService { get; set; }

        [ImportMany]
        private IEnumerable<Lazy<BCad.Commands.ICommand, ICommandMetadata>> Commands = null;

        [ImportMany]
        private IEnumerable<IFileWriter> FileWriters = null;

        #endregion

        #region IWorkspace implementation

        public ISettingsManager SettingsManager { get; private set; }

        public void Update(Drawing drawing = null, Plane drawingPlane = null)
        {
            var e = new WorkspaceChangeEventArgs(drawing != null, drawingPlane != null);

            OnWorkspaceChanging(drawing != null, drawingPlane != null);
            this.drawing = drawing;
            this.drawingPlane = drawingPlane;
            OnWorkspaceChanged(drawing != null, drawingPlane != null);
        }

        public event WorkspaceChangingEventHandler WorkspaceChanging;

        protected void OnWorkspaceChanging(bool isDrawingChanging, bool isDrawingPlaneChanging)
        {
            var handler = WorkspaceChanging;
            if (handler != null)
                handler(this, new WorkspaceChangeEventArgs(isDrawingChanging, isDrawingPlaneChanging));
        }

        public event WorkspaceChangedEventHandler WorkspaceChanged;
<commit_msg>don't allow null to be set in IWorkspace.Update()<commit_after>﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Composition;
using System.ComponentModel.Composition.Primitives;
using System.IO;
using System.Linq;
using System.Threading;
using System.Windows;
using System.Xml.Serialization;
using BCad.Collections;
using BCad.Commands;
using BCad.Entities;
using BCad.EventArguments;
using BCad.FileHandlers;
using BCad.Services;

namespace BCad
{
    [Export(typeof(IWorkspace))]
    internal class Workspace : IWorkspace
    {
        public Workspace()
        {
            LoadSettings(ConfigFile);
        }

        #region Events

        public event CommandExecutingEventHandler CommandExecuting;

        protected virtual void OnCommandExecuting(CommandExecutingEventArgs e)
        {
            if (CommandExecuting != null)
                CommandExecuting(this, e);
        }

        public event CommandExecutedEventHandler CommandExecuted;

        protected virtual void OnCommandExecuted(CommandExecutedEventArgs e)
        {
            if (CommandExecuted != null)
                CommandExecuted(this, e);
        }

        #endregion

        #region Properties

        private Drawing drawing = new Drawing();
        public Drawing Drawing
        {
            get { return drawing; }
        }

        private Plane drawingPlane = new Plane(Point.Origin, Vector.ZAxis);
        public Plane DrawingPlane
        {
            get { return drawingPlane; }
        }

        private ObservableHashSet<Entity> selectedEntities = new ObservableHashSet<Entity>();
        public ObservableHashSet<Entity> SelectedEntities
        {
            get { return selectedEntities; }
        }

        #endregion

        #region Imports

        [Import]
        private IInputService InputService = null;

        // required so that the service is created before the undo or redo commands are fired
        [Import]
        private IUndoRedoService UndoRedoService { get; set; }

        [ImportMany]
        private IEnumerable<Lazy<BCad.Commands.ICommand, ICommandMetadata>> Commands = null;

        [ImportMany]
        private IEnumerable<IFileWriter> FileWriters = null;

        #endregion

        #region IWorkspace implementation

        public ISettingsManager SettingsManager { get; private set; }

        public void Update(Drawing drawing = null, Plane drawingPlane = null)
        {
            bool drawingChange = drawing != null;
            bool drawingPlaneChange = drawingPlane != null;

            OnWorkspaceChanging(drawingChange, drawingPlaneChange);
            if (drawing != null)
                this.drawing = drawing;
            if (drawingPlane != null)
                this.drawingPlane = drawingPlane;
            OnWorkspaceChanged(drawingChange, drawingPlaneChange);
        }

        public event WorkspaceChangingEventHandler WorkspaceChanging;

        protected void OnWorkspaceChanging(bool isDrawingChanging, bool isDrawingPlaneChanging)
        {
            var handler = WorkspaceChanging;
            if (handler != null)
                handler(this, new WorkspaceChangeEventArgs(isDrawingChanging, isDrawingPlaneChanging));
        }

        public event WorkspaceChangedEventHandler WorkspaceChanged;

{'fraction_non_alphanumeric': 0.06643249847281613, 'fraction_numerical': 0.0, 'mean_word_length': 2.477960701009028, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '183510', 'n_tokens_mistral': 1638, 'n_tokens_neox': 1627, 'n_words': 430}