Esempio n. 1
0
        protected override BasicHierachicalNote CreateClone()
        {
            var n = new FilesystemNote(_id, _config);

            using (n.SuppressDirtyChanges())
            {
                n._text             = _text;
                n._title            = _title;
                n._path             = _path;
                n._pathRemote       = _pathRemote;
                n._creationDate     = _creationDate;
                n._modificationDate = _modificationDate;
                return(n);
            }
        }
Esempio n. 2
0
        private FilesystemNote ReadNoteFromPath(string path)
        {
            var info = new FileInfo(path);

            var note = new FilesystemNote(Guid.NewGuid(), _config);

            using (note.SuppressDirtyChanges())
            {
                note.Title            = Path.GetFileNameWithoutExtension(info.FullName);
                note.Path             = ANFileSystemUtil.GetDirectoryPath(_config.Folder, info.DirectoryName);
                note.Text             = File.ReadAllText(info.FullName, _config.Encoding);
                note.CreationDate     = info.CreationTime;
                note.ModificationDate = info.LastWriteTime;
                note.PathRemote       = info.FullName;
                note.IsLocked         = info.IsReadOnly;
            }

            return(note);
        }
Esempio n. 3
0
        public override RemoteDownloadResult UpdateNoteFromRemote(INote inote)
        {
            FilesystemNote note = (FilesystemNote)inote;

            var path = note.GetPath(_config);
            var fi   = new FileInfo(path);

            if (!fi.Exists)
            {
                return(RemoteDownloadResult.DeletedOnRemote);
            }

            using (note.SuppressDirtyChanges())
            {
                note.Title            = Path.GetFileNameWithoutExtension(path);
                note.Text             = File.ReadAllText(path, _config.Encoding);
                note.PathRemote       = path;
                note.ModificationDate = fi.LastWriteTime;
                note.IsLocked         = fi.IsReadOnly;
            }

            return(RemoteDownloadResult.Updated);
        }