Example #1
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);
       }
 }
Example #2
0
        public void AddSession(Session session)
        {
            if (session == null)
            throw new ArgumentNullException("session");

              if (GetSession(session.Name) != null)
            throw new Exception(string.Format("Trying to add duplicated session: {0}", session.Name));

              session.IsDirty = true;
              _sessionsCache.Add(session);
        }
Example #3
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;
            }

              }
        }
Example #4
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);
        }
Example #5
0
        public IEnumerable<Session> GetAllSessions()
        {
            var repositoryFile = getRepositoryFile();

              var sessionsList = new List<Session>();

              var xmlSessionsNode = getSecondLevelNode(repositoryFile, TAG_SESSIONS);

              foreach (XmlNode sessionNode in xmlSessionsNode)
              {
            var session = new Session(sessionNode.Attributes[ATTRIBUTE_SESSION_NAME].Value);

            foreach (XmlNode documentNode in sessionNode.ChildNodes[0].ChildNodes)
            {
              var document = new SessionDocument(documentNode.Attributes[ATTRIBUTE_DOC_PATH].Value,
            (DocumentType)Enum.Parse(typeof(DocumentType), documentNode.Attributes[ATTRIBUTE_DOC_TYPE].Value));
              session.AddDocument(document);
            }

            sessionsList.Add(session);
              }

              return sessionsList.AsEnumerable();
        }
        public IEnumerable<Session> GetAllSessions()
        {
            var sessions = new Collection<Session>();

              var s1 = new Session("Class1 + Class2");
              s1.AddDocument(new SessionDocument(@"c:\VSProjects\Prueba1\ClassLibrary2\Class1.cs", DocumentType.Text));
              s1.AddDocument(new SessionDocument(@"c:\VSProjects\Prueba1\ClassLibrary1\Class2.cs", DocumentType.Text));
              sessions.Add(s1);

              var s2 = new Session("Class1");
              s2.AddDocument(new SessionDocument(@"c:\VSProjects\Prueba1\ClassLibrary2\Class1.cs", DocumentType.Text));
              s2.AddDocument(new SessionDocument(@"c:\VSProjects\Prueba1\ClassLibrary2\pepe.cs", DocumentType.Text));
              sessions.Add(s2);

              var s3 = new Session("Class2 + Form1");
              s3.AddDocument(new SessionDocument(@"c:\VSProjects\Prueba1\ClassLibrary1\Class2.cs", DocumentType.Text));
              s3.AddDocument(new SessionDocument(@"c:\VSProjects\Prueba1\ClassLibrary1\Form1.cs", DocumentType.Designer));
              s3.AddDocument(new SessionDocument(@"c:\VSProjects\Prueba1\ClassLibrary1\Form1.cs", DocumentType.Text));
              s3.AddDocument(new SessionDocument(@"c:\VSProjects\Prueba1\ClassLibrary1\XMLFile1.xml", DocumentType.Text));
              s3.AddDocument(new SessionDocument(@"c:\VSProjects\Prueba1\ClassLibrary1\ClassDiagram1.cd", DocumentType.Text));
              sessions.Add(s3);

              return sessions;
        }
Example #7
0
        public void SaveSessionAs()
        {
            IList<SessionDto> dtoList = getSessionDtoList(_sessionManager.GetSessions());
              SessionDto newSessionDto = _viewAdapter.GetSessionForSaveAs(dtoList);

              if (newSessionDto != null)
              {
            Session newSession;

            Session sessionToReplace = _sessionManager.GetSession(newSessionDto.Name);
            if (sessionToReplace != null)
            {
              newSession = sessionToReplace;
              newSession.RemoveAllDocuments();
            }
            else
            {
              newSession = new Session(newSessionDto.Name);
              _sessionManager.AddSession(newSession);
            }

            _sessionManager.CurrentSession = newSession;
            _selectedSessionName = newSession.Name;

            FillDocumentsInSession(newSession);

            _sessionManager.Persist();
              }
        }
Example #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);
              }
        }
Example #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);
        }
Example #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);
        }
Example #11
0
        private void addSessionNode(XmlNode rootSessions, Session session)
        {
            var xmlSessionNode = rootSessions.OwnerDocument.CreateElement("", TAG_SESSION, "");
              xmlSessionNode.SetAttributeNode(ATTRIBUTE_SESSION_NAME, "").Value = session.Name;
              rootSessions.AppendChild(xmlSessionNode);

              fillDocuments(session, xmlSessionNode);
        }
Example #12
0
 private static bool match(XmlNode node, Session session)
 {
     return node.Name.Equals(TAG_SESSION) &&
     node.Attributes[ATTRIBUTE_SESSION_NAME].Value.Equals(session.Name);
 }
Example #13
0
        public void RemoveSession(Session session)
        {
            if (session == null)
            throw new ArgumentNullException("session");

              if (GetSession(session.Name) == null)
            throw new Exception(string.Format("Trying to remove non existent session: {0}", session.Name));

              _removedSessionsCache.Add(session);
              _sessionsCache.Remove(session);

              if ((_currentSession != null) && (_currentSession.Equals(session)))
            _currentSession = null;
        }
Example #14
0
 public SessionBuilder StartDefault()
 {
     _session = new Session("DEFAULT_SESSION");
       return this;
 }
Example #15
0
 public SessionBuilder StartDefault(string sessionName)
 {
     _session = new Session(sessionName);
       return this;
 }
Example #16
0
        private void DebuggerEvents_OnEnterRunMode(dbgEventReason Reason)
        {
            if (!_debuggerRunning && reasonIsStartDebugger(Reason))
              {
            _debuggerRunning = true;

            _preDebugSession = new Session("preDebugSession");
            _controller.FillDocumentsInSession(_preDebugSession);
              }
        }