Пример #1
0
        private static void ProcessDirectory(string targetDirectory, Engine appEngine)
        {
            DiskStorage noteStorage = new DiskStorage (targetDirectory);
            Engine noteEngine = new Engine (noteStorage);
            Dictionary<string,Note> notes = new Dictionary<string,Note>();

            try {
                notes = noteEngine.GetNotes ();
            } catch (ArgumentException) {
                Console.WriteLine ("Found an exception with {0}",targetDirectory);
            }

            foreach (Note note in notes.Values) {

                Note newNote = appEngine.NewNote ();
                newNote.ChangeDate = note.ChangeDate;
                newNote.CreateDate = note.CreateDate;
                newNote.CursorPosition = note.CursorPosition;
                newNote.Height = note.Height;
                newNote.MetadataChangeDate = note.MetadataChangeDate;
                newNote.Notebook = note.Notebook;
                newNote.OpenOnStartup = note.OpenOnStartup;
                newNote.SelectionBoundPosition = note.SelectionBoundPosition;
                newNote.Tags = note.Tags;
                newNote.Text = note.Text;
                newNote.Title = note.Title;
                newNote.Width = note.Width;
                newNote.X = note.X;
                newNote.Y = note.Y;
                appEngine.SaveNote (newNote, false);

                Console.WriteLine ("Imported the Note {0}",newNote.Title);
            }

            string [] subdirectoryEntries = System.IO.Directory.GetDirectories(targetDirectory);
            foreach(string subdirectory in subdirectoryEntries)
                ProcessDirectory(subdirectory, appEngine);
        }
Пример #2
0
        public void Init()
        {
            IPortableIoC container = new PortableIoc ();
            container.Register<DiskStorage> (c => {
                return new DiskStorage ("../../test_notes/proper_notes") {
                    Logger = new ConsoleLogger ()
                };
            });
            diskStorage = container.Resolve<DiskStorage> ();

            engine = new Engine (diskStorage);
            // get a new note instance
            note = engine.NewNote ();
            note.Title = "Unit Test Note";
            note.Text = "Unit test note by NewNote() method";
            engine.SaveNote (note);
            NOTE_PATH = Path.Combine ("../../test_notes/proper_notes", Utils.GetNoteFileNameFromURI (note));
        }
Пример #3
0
 public void Init()
 {
     //TODO: The storage instance needs swapping with a stub/mock!
     DiskStorage.Instance.SetPath ("../../test_notes/proper_notes");
     engine = new Engine (DiskStorage.Instance);
     // get a new note instance
     note = engine.NewNote ();
     note.Title = "Unit Test Note";
     note.Text = "Unit test note by NewNote() method";
     engine.SaveNote (note);
     NOTE_PATH = Path.Combine ("../../test_notes/proper_notes", Utils.GetNoteFileNameFromURI (note));
 }