本文整理汇总了C#中TaskList.LoadTasks方法的典型用法代码示例。如果您正苦于以下问题:C# TaskList.LoadTasks方法的具体用法?C# TaskList.LoadTasks怎么用?C# TaskList.LoadTasks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TaskList
的用法示例。
在下文中一共展示了TaskList.LoadTasks方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
示例2: 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);
}
示例3: MergeTaskLists
private void MergeTaskLists(string remoteTaskContents)
{
// We need a tasklist from the original remote file
var original = new TaskList();
using(IsolatedStorageFile appStorage = IsolatedStorageFile.GetUserStoreForApplication())
{
if(appStorage.FileExists("MergeCache"))
{
using(IsolatedStorageFileStream file = appStorage.OpenFile("MergeCache", FileMode.Open, FileAccess.Read))
{
original.LoadTasks(file);
}
}
}
// Now we need the new remote task list
var tl = new TaskList();
using (var ms = new MemoryStream(
Encoding.UTF8.GetBytes(remoteTaskContents)))
{
tl.LoadTasks(ms);
}
// Now that we have the original and updated remote versions, we can merge them
// with the local version
LoadingState = TaskLoadingState.Loading;
lock(_syncLock)
{
PauseCollectionChanged();
ClearTaskPropertyChangedHandlers();
var newTaskList = TaskList.Merge(original, tl, _taskList);
_taskList.Clear();
foreach(var task in newTaskList)
{
_taskList.Add(task);
}
SaveToStorage();
PushLocal();
InitTaskPropertyChangedHandlers();
ResumeCollectionChanged();
}
InvokeTaskListChanged(new TaskListChangedEventArgs());
LoadingState = TaskLoadingState.Ready;
}
示例4: Load_From_Stream
public void Load_From_Stream()
{
using (FileStream fs = File.OpenRead(_testDataPath))
{
var tl = new TaskList();
tl.LoadTasks(fs);
Assert.AreEqual(8, tl.Count);
}
}
示例5: Load_From_Stream_Repeated
public void Load_From_Stream_Repeated()
{
var s = new Stopwatch();
s.Start();
for (int n = 0; n < 500; n++)
{
using (FileStream fs = File.OpenRead(_testDataPath))
{
var tl = new TaskList();
tl.LoadTasks(fs);
}
}
s.Stop();
Debug.WriteLine(s.Elapsed);
}