Exemplo n.º 1
0
        private void DebuggerEvents_OnEnterDesignMode(dbgEventReason Reason)
        {
            if (_debuggerRunning && reasonIsStopDebugger(Reason))
            {
                _debuggerRunning = false;

                try
                {
                    if (_settingsManager.DsmSettings.RestoreOpenedDocumentsAfterDebug)
                    {
                        var postDebugSession = new Session("postDebugSession");
                        _controller.FillDocumentsInSession(postDebugSession);

                        bool documentsChanged = false;

                        if (_preDebugSession.GetDocuments().Count() != postDebugSession.GetDocuments().Count())
                        {
                            documentsChanged = true;
                        }
                        else
                        {
                            var postDebugSessionDocs = postDebugSession.GetDocuments();
                            foreach (var doc in _preDebugSession.GetDocuments())
                            {
                                if (!postDebugSessionDocs.Contains(doc))
                                {
                                    documentsChanged = true;
                                    break;
                                }
                            }
                        }

                        if (documentsChanged)
                        {
                            if (!_settingsManager.DsmSettings.AskConfirmationRestoreDocs ||
                                _viewAdapter.AskForConfirmation("Do you want to restore the documents as they were before start debugging ?\r\n" +
                                                                "(Please note that closed documents can be re-opened later through the 'Recently Closed Documents' addin button)"))
                            {
                                _controller.LoadDocumentsFromSession(_preDebugSession);
                            }
                        }
                    }
                }
                finally
                {
                    _preDebugSession = null;
                }
            }
        }
Exemplo n.º 2
0
        private void DebuggerEvents_OnEnterDesignMode(dbgEventReason Reason)
        {
            if (_debuggerRunning && reasonIsStopDebugger(Reason))
              {
            _debuggerRunning = false;

            try
            {
              if (_settingsManager.DsmSettings.RestoreOpenedDocumentsAfterDebug)
              {
            var postDebugSession = new Session("postDebugSession");
            _controller.FillDocumentsInSession(postDebugSession);

            bool documentsChanged = false;

            if (_preDebugSession.GetDocuments().Count() != postDebugSession.GetDocuments().Count())
              documentsChanged = true;
            else
            {
              var postDebugSessionDocs = postDebugSession.GetDocuments();
              foreach (var doc in _preDebugSession.GetDocuments())
              {
                if (!postDebugSessionDocs.Contains(doc))
                {
                  documentsChanged = true;
                  break;
                }
              }
            }

            if (documentsChanged)
            {
              if (!_settingsManager.DsmSettings.AskConfirmationRestoreDocs ||
                _viewAdapter.AskForConfirmation("Do you want to restore the documents as they were before start debugging ?\r\n" +
                "(Please note that closed documents can be re-opened later through the 'Recently Closed Documents' addin button)"))
              {
                _controller.LoadDocumentsFromSession(_preDebugSession);
              }
            }
              }
            }
            finally
            {
              _preDebugSession = null;
            }

              }
        }
Exemplo n.º 3
0
        public void FillDocumentsInSession(Session s)
        {
            var currentDocuments = new List <SessionDocument>();

            foreach (var window in _dteAdapter.GetWindowsForValidDocuments())
            {
                var doc = new SessionDocument(window.FullPath, window.DocumentType);
                currentDocuments.Add(doc);
            }

            var sessionDocuments = new List <SessionDocument>(s.GetDocuments());

            for (int i = sessionDocuments.Count - 1; i >= 0; i--)
            {
                if (!currentDocuments.Contains(sessionDocuments[i]))
                {
                    s.RemoveDocument(sessionDocuments[i]);
                }
            }

            foreach (var currDoc in currentDocuments)
            {
                s.AddDocument(currDoc);
            }
        }
Exemplo n.º 4
0
 public static void MapObjToDto(Session obj, SessionDto dto)
 {
     dto.Name = obj.Name;
     foreach (var doc in obj.GetDocuments())
     {
         var dtoDoc = new SessionDocumentDto();
         DtoMapper.MapObjToDto(doc, dtoDoc);
         dto.Documents.Add(dtoDoc);
     }
 }
Exemplo n.º 5
0
 public static void MapObjToDto(Session obj, SessionDto dto)
 {
     dto.Name = obj.Name;
       foreach (var doc in obj.GetDocuments())
       {
     var dtoDoc = new SessionDocumentDto();
     DtoMapper.MapObjToDto(doc, dtoDoc);
     dto.Documents.Add(dtoDoc);
       }
 }
Exemplo n.º 6
0
        public void TestSessionMapObjToDto()
        {
            var session = new Session("session");
              var sessionDocument = new SessionDocument("path", DocumentType.Designer);
              session.AddDocument(sessionDocument);

              var sessionDto = new SessionDto();

              DtoMapper.MapObjToDto(session, sessionDto);

              Assert.AreEqual(session.Name, sessionDto.Name);

              Assert.AreEqual(session.GetDocuments().Count(), sessionDto.DocumentsCount);

              Assert.AreEqual(sessionDocument.Path, sessionDto.Documents[0].Path);
              Assert.AreEqual(sessionDocument.Type, sessionDto.Documents[0].Type);
        }
Exemplo n.º 7
0
        private void fillDocuments(Session session, XmlNode sessionNode)
        {
            XmlNode xmlDocumentsNode;

            if (sessionNode.ChildNodes.Count == 0)
            {
                xmlDocumentsNode = sessionNode.OwnerDocument.CreateElement("", TAG_DOCUMENTS, "");
                sessionNode.AppendChild(xmlDocumentsNode);
            }
            else
            {
                xmlDocumentsNode = sessionNode.FirstChild;
            }

            xmlDocumentsNode.RemoveAll();

            foreach (var d in session.GetDocuments())
            {
                addDocumentNode(xmlDocumentsNode, d);
            }
        }
Exemplo n.º 8
0
        public void LoadDocumentsFromSession(Session session)
        {
            try
              {
            bool cancelled = false;

            var localClosedDocs = new List<SessionDocument>();

            var documents = new List<SessionDocument>(session.GetDocuments());

            foreach (var window in _dteAdapter.GetWindowsForValidDocuments())
            {
              int index = -1;
              for (int i = 0; i < documents.Count; i++)
              {
            if (window.DocumentMatches(documents[i]))
            {
              index = i;
              break;
            }
              }

              if (index < 0)
              {
            string fullPath = window.FullPath;
            DocumentType documentType = window.DocumentType;

            if (!window.Close(SaveChanges.Prompt))
            {
              cancelled = true;
              break;
            }
            else
              localClosedDocs.Insert(0, new SessionDocument(fullPath, documentType));

              }
              else
            documents.RemoveAt(index);
            }

            if (localClosedDocs.Count > 0)
            {
              AddDocumentsToRecentlyClosedList(_recentlyClosedDocs, localClosedDocs);
            }

            if (!cancelled)
            {
              StringBuilder errors = new StringBuilder();
              foreach (SessionDocument document in documents)
              {
            if (!_dteAdapter.FileExists(document.Path))
              errors.AppendLine(document.Path);
            else
              _dteAdapter.OpenFile(document.Path, document.Type);
              }

              if (errors.Length > 0)
              {
            _viewAdapter.ShowLongMessage("Warning", "The following documents could not be found", errors.ToString());
              }
            }
              }
              catch (Exception ex)
              {
            _exceptionManager.HandleException(ex);
              }
        }
Exemplo n.º 9
0
        public void FillDocumentsInSession(Session s)
        {
            var currentDocuments = new List<SessionDocument>();

              foreach (var window in _dteAdapter.GetWindowsForValidDocuments())
              {
            var doc = new SessionDocument(window.FullPath, window.DocumentType);
            currentDocuments.Add(doc);
              }

              var sessionDocuments = new List<SessionDocument>(s.GetDocuments());
              for (int i = sessionDocuments.Count - 1; i >= 0; i--)
              {
            if (!currentDocuments.Contains(sessionDocuments[i]))
              s.RemoveDocument(sessionDocuments[i]);
              }

              foreach (var currDoc in currentDocuments)
            s.AddDocument(currDoc);
        }
Exemplo n.º 10
0
        private void fillDocuments(Session session, XmlNode sessionNode)
        {
            XmlNode xmlDocumentsNode;
              if (sessionNode.ChildNodes.Count == 0)
              {
            xmlDocumentsNode = sessionNode.OwnerDocument.CreateElement("", TAG_DOCUMENTS, "");
            sessionNode.AppendChild(xmlDocumentsNode);
              }
              else
            xmlDocumentsNode = sessionNode.FirstChild;

              xmlDocumentsNode.RemoveAll();

              foreach (var d in session.GetDocuments())
            addDocumentNode(xmlDocumentsNode, d);
        }
Exemplo n.º 11
0
        public void LoadDocumentsFromSession(Session session)
        {
            try
            {
                bool cancelled = false;

                var localClosedDocs = new List <SessionDocument>();

                var documents = new List <SessionDocument>(session.GetDocuments());

                foreach (var window in _dteAdapter.GetWindowsForValidDocuments())
                {
                    int index = -1;
                    for (int i = 0; i < documents.Count; i++)
                    {
                        if (window.DocumentMatches(documents[i]))
                        {
                            index = i;
                            break;
                        }
                    }

                    if (index < 0)
                    {
                        string       fullPath     = window.FullPath;
                        DocumentType documentType = window.DocumentType;

                        if (!window.Close(SaveChanges.Prompt))
                        {
                            cancelled = true;
                            break;
                        }
                        else
                        {
                            localClosedDocs.Insert(0, new SessionDocument(fullPath, documentType));
                        }
                    }
                    else
                    {
                        documents.RemoveAt(index);
                    }
                }

                if (localClosedDocs.Count > 0)
                {
                    AddDocumentsToRecentlyClosedList(_recentlyClosedDocs, localClosedDocs);
                }

                if (!cancelled)
                {
                    StringBuilder errors = new StringBuilder();
                    foreach (SessionDocument document in documents)
                    {
                        if (!_dteAdapter.FileExists(document.Path))
                        {
                            errors.AppendLine(document.Path);
                        }
                        else
                        {
                            _dteAdapter.OpenFile(document.Path, document.Type);
                        }
                    }

                    if (errors.Length > 0)
                    {
                        _viewAdapter.ShowLongMessage("Warning", "The following documents could not be found", errors.ToString());
                    }
                }
            }
            catch (Exception ex)
            {
                _exceptionManager.HandleException(ex);
            }
        }