Example #1
0
 		public static Note ParseNote (FileInfo file)
		{
			// Tomboy uses .note files.
			// Don't index the backup folder.
			if (file.Extension != ".note" 
			    || file.DirectoryName.EndsWith ("/Backup")) {
				return null;
			}

			// Create new note instance
			Note note = new TomboyNote(file.FullName);
			note.timestamp = file.LastWriteTimeUtc;

			// Parse XML info from file
			StreamReader reader = new StreamReader (file.FullName, System.Text.Encoding.UTF8);
			XmlTextReader doc = new XmlTextReader (reader);
			doc.Namespaces = false;

			bool read_text = false;
			StringBuilder sb = new StringBuilder ();

			while (doc.Read ()) {
				// FIXME: Extract more information than mere text from the tags in note-content
				// for hottext, linking notes etc.
				if (doc.NodeType == XmlNodeType.Element && doc.Name == "note-content") {
					read_text = true;
					continue;
				}

				if (doc.NodeType == XmlNodeType.EndElement && doc.Name == "note-content") {
					read_text = false;
					continue;
				}

				if (doc.NodeType == XmlNodeType.Element && doc.Name == "title") {
					note.subject = doc.ReadString ();
					continue;
				}
				if (doc.NodeType == XmlNodeType.Element && doc.Name == "tag"){
					note.tags.Add(doc.ReadString());
					continue;
				}

				if (doc.NodeType == XmlNodeType.Text) {
					if (read_text)
						sb.Append (doc.Value);
					continue;
				}
			}

			doc.Close ();
			note.text = sb.ToString ();

			return note;
		}
Example #2
0
        public static Note ParseNote(FileInfo file)
        {
            // Tomboy uses .note files.
            // Don't index the backup folder.
            if (file.Extension != ".note" ||
                file.DirectoryName.EndsWith("/Backup"))
            {
                return(null);
            }

            // Create new note instance
            Note note = new TomboyNote(file.FullName);

            note.timestamp = file.LastWriteTimeUtc;

            // Parse XML info from file
            StreamReader  reader = new StreamReader(file.FullName, System.Text.Encoding.UTF8);
            XmlTextReader doc    = new XmlTextReader(reader);

            doc.Namespaces = false;

            bool          read_text = false;
            StringBuilder sb        = new StringBuilder();

            while (doc.Read())
            {
                // FIXME: Extract more information than mere text from the tags in note-content
                // for hottext, linking notes etc.
                if (doc.NodeType == XmlNodeType.Element && doc.Name == "note-content")
                {
                    read_text = true;
                    continue;
                }

                if (doc.NodeType == XmlNodeType.EndElement && doc.Name == "note-content")
                {
                    read_text = false;
                    continue;
                }

                if (doc.NodeType == XmlNodeType.Element && doc.Name == "title")
                {
                    note.subject = doc.ReadString();
                    continue;
                }
                if (doc.NodeType == XmlNodeType.Element && doc.Name == "tag")
                {
                    note.tags.Add(doc.ReadString());
                    continue;
                }

                if (doc.NodeType == XmlNodeType.Text)
                {
                    if (read_text)
                    {
                        sb.Append(doc.Value);
                    }
                    continue;
                }
            }

            doc.Close();
            note.text = sb.ToString();

            return(note);
        }