示例#1
0
        // for running from IDE only. Replace with "." for release!

        public static void Main(string[] args)
        {
            // loading tasks
            List <Task> tasks = Task.LoadTasks();

            Console.WriteLine("Total of {0} tasks", tasks.Count);
            foreach (Task a in tasks)
            {
                Console.WriteLine("ID: {0}, Title: {1}, Weight: {2}, Parent: {3}", a.id, a.title, a.weight, a.parent);
            }

            Console.WriteLine("-- Changing Task");
            Task.ChangeTask(tasks, 1, "title", "Alarm Clock");

            Console.WriteLine("-- Adding Task");
            Task.AddTask(tasks, 6, "Have fun", 10, -1);

// Разбираем порядок сортировки
            Sort[] sort = Sort.LoadSorts();

/*	        Sort[] sort = new Sort[3];
 *              sort[0] = new Sort();
 *              sort[0].Property = "id";
 *              sort[0].Direction = "Asc";
 *              sort[1] = new Sort();
 *              sort[1].Property = "weight";
 *              sort[1].Direction = "Dsc";
 *              sort[2] = new Sort();
 *              sort[2].Property = "title";
 *              sort[2].Direction = "Dsc";
 */
            for (int j = 0; j < sort.Length; j++)
            {
                Console.WriteLine("{0} - {1}", sort[j].Property, sort[j].Direction);
            }

            List <Task> NTasks = Sort.DoSort <Task>(tasks, sort).ToList();

            Console.WriteLine("----->");
//	        List<Task> SortedTasks = Tasks.OrderBy(t => t.id).ThenBy(t => t.weight).ToList();
            foreach (Task a in NTasks)
            {
                Console.WriteLine("ID: {0}, Title: {1}, Weight: {2}, Parent {3}", a.id, a.title, a.weight, a.parent);
            }
            Console.ReadKey(true);
        }