• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# ToDoLib.Task类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: Create_CreationDate

        public void Create_CreationDate()
        {
            var task = new Task("(A) 2011-05-07 due:2011-05-08 @work @home +test This is a test task");

            Assert.AreEqual("2011-05-07", task.CreationDate);
        }
开发者ID:firefueled,项目名称:todotxt.net,代码行数:6,代码来源:TaskTests.cs


示例17: Create_CompletedData

        public void Create_CompletedData()
        {
            var task = new Task("X 2011-05-10 (A) @work +test This is a test task");

            Assert.AreEqual("2011-05-10", task.CompletedDate);
        }
开发者ID:firefueled,项目名称:todotxt.net,代码行数:6,代码来源:TaskTests.cs


示例18: Completed_adds_x_to_begining

        public void Completed_adds_x_to_begining()
        {
            var t = new Task("A new task");
            t.Completed = true;


        }
开发者ID:steppsr,项目名称:todotxt.net,代码行数:7,代码来源:TaskTests.cs


示例19: Task_Complete_with_over_due_date

 public void Task_Complete_with_over_due_date()
 {
     var t = new Task("x Task Complete with overdue date due:" + DateTime.Now.AddDays(-2).ToString("yyyy-MM-dd"));
     Assert.AreEqual(t.IsTaskDue, 1);
 }
开发者ID:balinjdl,项目名称:todotxt.net,代码行数:5,代码来源:TaskTests.cs


示例20: Delete_InFile

        public void Delete_InFile()
        {
            var fileContents = File.ReadAllLines(Data.TestDataPath).ToList();
            var task = new Task(fileContents.Last());
            fileContents.Remove(fileContents.Last());

            var tl = new TaskList(Data.TestDataPath);
            tl.Delete(task);

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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ToDoList.Category类代码示例发布时间:2022-05-26
下一篇:
C# Interfaces.tgDataResponse类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap