本文整理汇总了C#中TaskList.Add方法的典型用法代码示例。如果您正苦于以下问题:C# TaskList.Add方法的具体用法?C# TaskList.Add怎么用?C# TaskList.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TaskList
的用法示例。
在下文中一共展示了TaskList.Add方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Add_Multiple
public void Add_Multiple()
{
var tl = new TaskList(_testDataPath);
int c = tl.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.Count());
}
示例2: Add_ToCollection
public void Add_ToCollection()
{
var task = new Task("(B) Add_ToCollection +test @task");
var tl = new TaskList(_testDataPath);
List<Task> tasks = tl.ToList();
tasks.Add(task);
tl.Add(task);
List<Task> newTasks = tl.ToList();
Assert.AreEqual(tasks.Count, newTasks.Count);
for (int i = 0; i < tasks.Count; i++)
Assert.AreEqual(tasks[i].ToString(), newTasks[i].ToString());
}
示例3: GetRunningTasks
TaskList GetRunningTasks()
{
var tl = new TaskList();
var processlist = Process.GetProcesses();
foreach (Process p in processlist)
{
var t = new Task();
t.Name = p.ProcessName;
t.ProcessId = p.Id;
t.PrivateMemory = p.PrivateMemorySize64;
t.WorkingSet = p.WorkingSet64;
//t.ProcessorTime = p.TotalProcessorTime; // access denied
tl.Add(t);
}
return tl;
}
示例4: Add_ToFile
public void Add_ToFile()
{
// Create a copy of test data so we can leave the original alone
string tempTaskFile = CreateTempTasksFile();
List<string> fileContents = File.ReadAllLines(tempTaskFile).ToList();
fileContents.Add("(B) Add_ToFile +test @task");
var task = new Task(fileContents.Last());
var tl = new TaskList(tempTaskFile);
tl.Add(task);
tl.SaveTasks(tempTaskFile);
string[] newFileContents = File.ReadAllLines(tempTaskFile);
CollectionAssert.AreEquivalent(fileContents, newFileContents);
// Clean up
File.Delete(tempTaskFile);
}
示例5: gatTaskList
internal static TaskList gatTaskList(HttpResponseMessage responce)
{
var taskList = new TaskList();
var jsonObj = JsonConvert.DeserializeObject<Dictionary<string, object>>(responce.Content.ReadAsStringAsync().Result);
if (jsonObj.ContainsKey("task"))
{
var tasksArray = JsonConvert.DeserializeObject<List<object>>(jsonObj["task"].ToString());
foreach(var taskObj in tasksArray)
{
var task = new ProjectTask();
task = JsonConvert.DeserializeObject<ProjectTask>(taskObj.ToString());
taskList.Add(task);
}
}
if (jsonObj.ContainsKey("page_context"))
{
var pageContext = new PageContext();
pageContext = JsonConvert.DeserializeObject<PageContext>(jsonObj["page_context"].ToString());
taskList.page_context = pageContext;
}
return taskList;
}
示例6: Add_To_Empty_File
public void Add_To_Empty_File()
{
// v0.3 and earlier contained a bug where a blank task was added
string tempTaskFile = CreateTempTasksFile();
File.WriteAllLines(tempTaskFile, new string[] {}); // empties the file
var tl = new TaskList(tempTaskFile);
tl.Add(new Task("A task"));
Assert.AreEqual(1, tl.Count());
// Clean up
File.Delete(tempTaskFile);
}
示例7: Update_InCollection
public void Update_InCollection()
{
var task = new Task("(B) Update_InCollection +test @task");
var tl = new TaskList(_testDataPath);
tl.Add(task);
var task2 = new Task(task.Raw);
task2.ToggleCompleted();
tl.Update(task, task2);
Task newTask = tl.Last();
Assert.IsTrue(newTask.Completed);
}
示例8: ToggleComplete_On_InCollection
public void ToggleComplete_On_InCollection()
{
var task = new Task("(B ToggleComplete_On_InCollection +test @task");
var tl = new TaskList(_testDataPath);
tl.Add(task);
task = tl.Last();
task.ToggleCompleted();
task = tl.Last();
Assert.IsTrue(task.Completed);
}
示例9: ToggleComplete_Off_InCollection
public void ToggleComplete_Off_InCollection()
{
// Not complete - doesn't include completed date
var task = new Task("X (B) ToggleComplete_Off_InCollection +test @task");
var tl = new TaskList(_testDataPath);
tl.Add(task);
task = tl.Last();
task.ToggleCompleted();
task = tl.Last();
Assert.IsTrue(task.Completed);
var task2 = new Task("X 2011-02-25 ToggleComplete_Off_InCollection +test @task");
tl.Add(task2);
task = tl.Last();
task.ToggleCompleted();
task = tl.Last();
Assert.IsFalse(task.Completed);
}
示例10: Save_To_Stream
public void Save_To_Stream()
{
string tempTaskFile = CreateTempTasksFile();
var tl = new TaskList();
using (FileStream fs = File.OpenRead(tempTaskFile))
{
tl.LoadTasks(fs);
}
tl.Add(new Task("This task should end up in both lists"));
string tempTaskFileCopy = CreateTempTasksFile();
using (FileStream fs = File.OpenWrite(tempTaskFileCopy))
{
tl.SaveTasks(fs);
}
var tl2 = new TaskList(tempTaskFileCopy);
Assert.AreEqual(tl.Count, tl2.Count);
}
示例11: ObservableChanges
public void ObservableChanges()
{
var tl = new TaskList();
bool fired = false;
tl.CollectionChanged += (sender, e) => { fired = true; };
tl.LoadTasks(_testDataPath);
Assert.True(fired);
fired = false;
tl.Add(new Task("T", null, null, "Test task for observablecollection event firing"));
Assert.True(fired);
fired = false;
tl[0].PropertyChanged += (sender, e) => { fired = true; };
tl[0].Append("Test append for propertychanged event firing");
Assert.True(fired);
}
示例12: GetScheduleQueue
public static TaskList<ScheduleHistory> GetScheduleQueue()
{
var c = new TaskList<ScheduleHistory>();
try
{
using (ScheduleQueue.GetReadLock(LockTimeout))
{
foreach (ScheduleHistory item in ScheduleQueue)
{
c.Add(item);
}
}
return c;
}
catch (ApplicationException ex)
{
Interlocked.Increment(ref _readerTimeouts);
ErrorLogger.SchedulerProcessException(ex);
}
return c;
}
示例13: MainViewModel
/// <summary>
/// Initializes a new instance of the MainViewModel class.
/// </summary>
public MainViewModel(PrimaryTaskFileService taskFileService, ArchiveTaskFileService archiveFileService, ApplicationSettings applicationSettings)
{
_applicationSettings = applicationSettings;
if (IsInDesignMode)
{
// Code runs in Blend --> create design time data.
TaskList = new TaskList
{
new Task("A", null, null,
"This is a designer task that might be really long the quick brown fox jumped over the lazy dogs"),
new Task("", null, null, "This is a designer task2"),
new Task("", null, null,
"This is a designer task3 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.")
};
var b = new Task("B", null, null, "This is a designer task4", DateTime.Now.AddDays(-1), null, false, null);
b.ToggleCompleted();
TaskList.Add(b);
TaskList.Add(new Task("C", null, null, "This is a designer task5"));
TaskList.Add(new Task("This task has two contexts @home @work"));
TaskList.Add(new Task("This task has two projects +planvacation +fixstove"));
TaskList.Add(new Task("This task has one of each @home +fixstove"));
TaskList.Add(new Task("")); // Blank task line
SelectedTask = TaskList[3];
ViewTask();
}
else
{
// Code runs "for real"
WireupTaskFileServices(taskFileService, archiveFileService);
Messenger.Default.Register<DrillDownMessage>(this, Filter);
Messenger.Default.Register<ApplicationStartedMessage>(this, message =>
{
LocalHasChanges = _taskFileService.LocalHasChanges;
if(StartupSyncCommand.CanExecute(null))
{
StartupSyncCommand.Execute(null);
}
});
WireUpCommands();
}
}