Example #1
0
        public static ToDoListVersion FindCorrectVersion(string path, out object resultTodoList)
        {
            resultTodoList = null;

            readerDelegate current = ToDoList.Deserialize;

            if (TryToRead(current, ref resultTodoList, path))
            {
                return(ToDoListVersion.Current);
            }


            FormatPre04.TodoList oldTodoList = new FormatPre04.TodoList();
            injectDelegate       xml         = oldTodoList.FromXml;

            if (TryToRead(xml, ref resultTodoList, path))
            {
                return(ToDoListVersion.Xml);
            }

            readerDelegate pre04 = FormatPre04.TodoList.DeserializeFromBinary;

            if (TryToRead(pre04, ref resultTodoList, path))
            {
                return(ToDoListVersion.Pre04);
            }


            return(ToDoListVersion.Unknown);
        }
Example #2
0
        private static ToDoList ConvertFromPre04(FormatPre04.TodoList list)
        {
            ToDoList result = new ToDoList();

            foreach (FormatPre04.Category cat in list.Categories)
            {
                foreach (FormatPre04.Task t in cat.Tasks)
                {
                    Task newTask = new Task();
                    newTask.Category = cat.Name;
                    newTask.SetIsDone(true);
                    newTask.DoneAt = t.DoneAt;
                    newTask.Text   = t.Text;
                    result.AddTask(newTask);
                }
            }
            return(result);
        }