Exemplo n.º 1
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            else if (object.ReferenceEquals(obj, this))
            {
                return(true);
            }
            else
            {
                SessionDocument objCast = obj as SessionDocument;
                if (objCast == null)
                {
                    return(false);
                }

                if ((this.Path.Equals(objCast.Path, StringComparison.OrdinalIgnoreCase)) && (this.Type == objCast.Type))
                {
                    return(true);
                }
            }

            return(base.Equals(obj));
        }
Exemplo n.º 2
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.º 3
0
        private static void addDocumentNode(XmlNode xmlDocumentsNode, SessionDocument document)
        {
            var xmlDocNode = xmlDocumentsNode.OwnerDocument.CreateElement("", TAG_DOCUMENT, "");

            xmlDocNode.SetAttributeNode(ATTRIBUTE_DOC_PATH, "").Value = document.Path;
            xmlDocNode.SetAttributeNode(ATTRIBUTE_DOC_TYPE, "").Value = document.Type.ToString();
            xmlDocumentsNode.AppendChild(xmlDocNode);
        }
Exemplo n.º 4
0
        public void TestSessionDocumentMapObjToDto()
        {
            var sessionDocument = new SessionDocument("path", DocumentType.Designer);
              var sessionDocumentDto = new SessionDocumentDto();

              DtoMapper.MapObjToDto(sessionDocument, sessionDocumentDto);

              Assert.AreEqual(sessionDocument.Path, sessionDocumentDto.Path);
              Assert.AreEqual(sessionDocument.Type, sessionDocumentDto.Type);
        }
Exemplo n.º 5
0
        public void AddDocument(SessionDocument document)
        {
            if (document == null)
            throw new ArgumentNullException("document");

              var doc = _documents.FirstOrDefault<SessionDocument>((d => d.Equals(document)));
              if (doc == null)
              {
            _documents.Add(document);
            _isDirty = true;
              }
        }
Exemplo n.º 6
0
        public void RemoveDocument(SessionDocument document)
        {
            if (document == null)
            {
                throw new ArgumentNullException("document");
            }

            var doc = _documents.FirstOrDefault <SessionDocument>((d => d.Equals(document)));

            if (doc != null)
            {
                _documents.Remove(doc);
                _isDirty = true;
            }
        }
Exemplo n.º 7
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.º 8
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();
        }
Exemplo n.º 9
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());
        }
Exemplo n.º 10
0
 public SessionDocumentBuilder StartDefault()
 {
     _sessionDocument = new SessionDocument("DEFAULT_PATH", DocumentType.Text);
       return this;
 }
Exemplo n.º 11
0
 public SessionDocumentBuilder StartDefault(string path)
 {
     _sessionDocument = new SessionDocument(path, DocumentType.Text);
       return this;
 }
Exemplo n.º 12
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.º 13
0
 public static void MapObjToDto(SessionDocument obj, SessionDocumentDto dto)
 {
     dto.Path = obj.Path;
     dto.Type = obj.Type;
 }
Exemplo n.º 14
0
 public bool DocumentMatches(SessionDocument document)
 {
     return((this.DocumentType == document.Type) &&
            (this.FullPath.Equals(document.Path, StringComparison.OrdinalIgnoreCase)));
 }
Exemplo n.º 15
0
 private static void addDocumentNode(XmlNode xmlDocumentsNode, SessionDocument document)
 {
     var xmlDocNode = xmlDocumentsNode.OwnerDocument.CreateElement("", TAG_DOCUMENT, "");
       xmlDocNode.SetAttributeNode(ATTRIBUTE_DOC_PATH, "").Value = document.Path;
       xmlDocNode.SetAttributeNode(ATTRIBUTE_DOC_TYPE, "").Value = document.Type.ToString();
       xmlDocumentsNode.AppendChild(xmlDocNode);
 }
Exemplo n.º 16
0
 public bool DocumentMatches(SessionDocument document)
 {
     return (this.DocumentType == document.Type) &&
     (this.FullPath.Equals(document.Path, StringComparison.OrdinalIgnoreCase));
 }
Exemplo n.º 17
0
 public static void MapObjToDto(SessionDocument obj, SessionDocumentDto dto)
 {
     dto.Path = obj.Path;
       dto.Type = obj.Type;
 }