当前位置: 首页>>代码示例>>C#>>正文


C# ToDoLib.Task类代码示例

本文整理汇总了C#中ToDoLib.Task的典型用法代码示例。如果您正苦于以下问题:C# Task类的具体用法?C# Task怎么用?C# Task使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Task类属于ToDoLib命名空间,在下文中一共展示了Task类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Create_Priority_In_Body

        public void Create_Priority_In_Body()
        {
            var task = new Task("Oh (A) This is a test task @work +test ");

            var expectedTask = new Task("", _projects, _contexts, "Oh (A) This is a test task");
            AssertEquivalence(expectedTask, task);
        }
开发者ID:steppsr,项目名称:todotxt.net,代码行数:7,代码来源:TaskTests.cs

示例2: Add

        public void Add(Task task)
        {
            try
            {
                var output = task.ToString();

                Log.Debug("Adding task '{0}'", output);

                var text = File.ReadAllText(_filePath);
                if (text.Length > 0 && !text.EndsWith(Environment.NewLine))
                    output = Environment.NewLine + output;

                File.AppendAllLines(_filePath, new string[] { output });

                Log.Debug("Task '{0}' added", output);

                ReloadTasks();
            }
            catch (IOException ex)
            {
                var msg = "An error occurred while trying to add your task to the task list file";
                Log.Error(msg, ex);
                throw new TaskException(msg, ex);
            }
            catch (Exception ex)
            {
                Log.Error(ex.ToString());
                throw;
            }

        }
开发者ID:slideep,项目名称:todotxt.net,代码行数:31,代码来源:TaskList.cs

示例3: Create_Priority_Context_Project_Body

        public void Create_Priority_Context_Project_Body()
        {
            var task = new Task("(A) @work +test This is a test task");

            var expectedTask = new Task("(A)", _projects, _contexts, "This is a test task");
            AssertEquivalence(expectedTask, task);
        }
开发者ID:steppsr,项目名称:todotxt.net,代码行数:7,代码来源:TaskTests.cs

示例4: Create_Trailing_Whitespace

        public void Create_Trailing_Whitespace()
        {
            var task = new Task("(A) This is a test task @work +test  ");

            var expectedTask = new Task("(A)", _projects, _contexts, "This is a test task");
            AssertEquivalence(expectedTask, task);
        }
开发者ID:steppsr,项目名称:todotxt.net,代码行数:7,代码来源:TaskTests.cs

示例5: Create_UnCompleted

        public void Create_UnCompleted()
        {
            var task = new Task("(A) @work +test This is a test task");

            var expectedTask = new Task("(A)", _projects, _contexts, "This is a test task");
            AssertEquivalence(expectedTask, task);
        }
开发者ID:steppsr,项目名称:todotxt.net,代码行数:7,代码来源:TaskTests.cs

示例6: Add_ToFile

        public void Add_ToFile()
        {
            var fileContents = File.ReadAllLines(Data.TestDataPath).ToList();
            fileContents.Add("(B) Add_ToFile +test @task");

            var task = new Task(fileContents.Last());
            var tl = new TaskList(Data.TestDataPath);
            tl.Add(task);

            var newFileContents = File.ReadAllLines(Data.TestDataPath);
            CollectionAssert.AreEquivalent(fileContents, newFileContents);
        }
开发者ID:robjefferies,项目名称:todotxt.net,代码行数:12,代码来源:TaskListTests.cs

示例7: Add_Multiple

        public void Add_Multiple()
        {
            var tl = new TaskList(Data.TestDataPath);
            var c = tl.Tasks.Count();

            var task = new Task("Add_Multiple task one");
            tl.Add(task);

            var task2 = new Task("Add_Multiple task two");
            tl.Add(task2);

            Assert.AreEqual(c + 2, tl.Tasks.Count());
        }
开发者ID:robjefferies,项目名称:todotxt.net,代码行数:13,代码来源:TaskListTests.cs

示例8: Delete

        public void Delete(Task task)
        {
            try
            {
                ReloadTasks(); // make sure we're working on the latest file
                if (_tasks.Remove(_tasks.First(t => t.Raw == task.Raw)))
                    File.WriteAllLines(_filePath, _tasks.Select(t => t.ToString()));

                ReloadTasks();
            }
            catch (IOException ex)
            {
                throw new TaskException("An error occurred while trying to remove your task from the task list file", ex);
            }
        }
开发者ID:pierskarsenbarg,项目名称:todotxt.net,代码行数:15,代码来源:TaskList.cs

示例9: Add_ToCollection

        public void Add_ToCollection()
        {
            var task = new Task("(B) Add_ToCollection +test @task");

            var tl = new TaskList(Data.TestDataPath);

            var tasks = new List<Task>(tl.Tasks);
            tasks.Add(task);

            tl.Add(task);

            var newTasks = tl.Tasks.ToList();

            Assert.AreEqual(tasks.Count, newTasks.Count);

            for (int i = 0; i < tasks.Count; i++)
                Assert.AreEqual(tasks[i].ToString(), newTasks[i].ToString());
        }
开发者ID:robjefferies,项目名称:todotxt.net,代码行数:18,代码来源:TaskListTests.cs

示例10: Update

        public void Update(Task currentTask, Task newTask)
        {
            try
            {
                ReloadTasks();
                var currentIndex = _tasks.IndexOf(_tasks.First(t => t.Raw == currentTask.Raw));

                _tasks[currentIndex] = newTask;

                File.WriteAllLines(_filePath, _tasks.Select(t => t.ToString()));
            }
            catch (IOException ex)
            {
                throw new TaskException("An error occurred while trying to update your task int the task list file", ex);
            }

            ReloadTasks();
        }
开发者ID:pierskarsenbarg,项目名称:todotxt.net,代码行数:18,代码来源:TaskList.cs

示例11: GetConsoleColorForTask

        static ConsoleColor GetConsoleColorForTask(Task task)
        {
            switch (task.Priority)
            {
                case "(A)":
                    return ConsoleColor.Yellow;

                case "(B)":
                    return ConsoleColor.Green;

                case "(C)":
                    return ConsoleColor.Blue;

                case "(D)":
                    return ConsoleColor.Magenta;
            }

            return Console.ForegroundColor;
        }
开发者ID:zeevl,项目名称:todo-exe,代码行数:19,代码来源:Program.cs

示例12: Add

        public void Add(Task task)
        {
            try
            {
                var output = task.ToString();

                var text = File.ReadAllText(_filePath);
                if (text.Length > 0 && !text.EndsWith(Environment.NewLine))
                    output = Environment.NewLine + output;

                File.AppendAllLines(_filePath, new string[] { output });

                ReloadTasks();
            }
            catch (IOException ex)
            {
                throw new TaskException("An error occurred while trying to add your task to the task list file", ex);
            }

        }
开发者ID:pierskarsenbarg,项目名称:todotxt.net,代码行数:20,代码来源:TaskList.cs

示例13: ReloadTasks

        public void ReloadTasks()
        {
            try
            {
                _tasks = new List<Task>();

                var i = 0;
                var file = File.OpenRead(_filePath);
                using (var reader = new StreamReader(file))
                {
                    string raw;
                    while ((raw = reader.ReadLine()) != null)
                    {
                        if (raw.Trim() == "")
                            continue;

                        var task = new Task(i++, raw);

                        Projects.AddRange(task.Projects.Where(s => !Projects.Contains(s)));
                        Contexts.AddRange(task.Contexts.Where(s => !Contexts.Contains(s)));

                        _tasks.Add(task);
                    }
                }

            }
            catch (IOException ex)
            {
                var msg = "There was a problem trying to read from your todo.txt file";
                throw new TaskException(msg, ex);
            }
        }
开发者ID:zeevl,项目名称:todo-exe,代码行数:32,代码来源:TaskList.cs

示例14: Update

		public void Update(Task currentTask, Task newTask)
		{
			try
			{
				Log.Debug("Updating task '{0}' to '{1}'", currentTask.ToString(), newTask.ToString());

				ReloadTasks();

				// ensure that the task list still contains the current task...
				if (!Tasks.Any(t => t.Raw == currentTask.Raw))
					throw new Exception("That task no longer exists in to todo.txt file");

				var currentIndex = Tasks.IndexOf(Tasks.First(t => t.Raw == currentTask.Raw));

				Tasks[currentIndex] = newTask;

				WriteAllTasksToFile();

				Log.Debug("Task '{0}' updated", currentTask.ToString());

				ReloadTasks();
			}
			catch (IOException ex)
			{
				var msg = "An error occurred while trying to update your task int the task list file";
				Log.Error(msg, ex);
				throw new TaskException(msg, ex);
			}
			catch (Exception ex)
			{
				Log.Error(ex.ToString());
				throw;
			}
		}
开发者ID:jerz4lunch,项目名称:todotxt.net,代码行数:34,代码来源:TaskList.cs

示例15: Delete_InCollection

        public void Delete_InCollection()
        {
            var task = new Task("(B) Delete_InCollection +test @task");
            var tl = new TaskList(Data.TestDataPath);
            tl.Add(task);

            var tasks = new List<Task>(tl.Tasks);
            tasks.Remove(tasks.Where(x => x.Raw == task.Raw).First());

            
            tl.Delete(task);

            var newTasks = tl.Tasks.ToList();

            Assert.AreEqual(tasks.Count, newTasks.Count);

            for (int i = 0; i < tasks.Count; i++)
                Assert.AreEqual(tasks[i].ToString(), newTasks[i].ToString());
        }
开发者ID:robjefferies,项目名称:todotxt.net,代码行数:19,代码来源:TaskListTests.cs


注:本文中的ToDoLib.Task类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。