Exemple #1
0
        public TaskFileResult ReadTasksFromFile(string path)
        {
            var list = new List <TodoTask>();

            if (!File.Exists(path))
            {
                return(new TaskFileResult(path, ReadResult.FileNotFound));
            }

            var lines = File.ReadAllLines(path);

            if ((lines.Length == 0) || (lines.Length == 1 && string.IsNullOrEmpty(lines[0])))
            {
                return(new TaskFileResult(path, ReadResult.NoContent));
            }

            if (TabPreambel.Match(lines[0]).Value.Length > 0)
            {
                return(new TaskFileResult(path, ReadResult.WrongFormat));
            }

            list.AddRange(ProcessLines(lines));

            var result = new TaskFileResult(path, ReadResult.ReadSuccess);

            result.AddData(list);
            return(result);
        }
Exemple #2
0
        public TaskFileResult ReadTasksFromList(List <string> list)
        {
            var result = new TaskFileResult("", ReadResult.ReadSuccess);

            result.AddData(ProcessLines(list));

            return(result);
        }