本文整理汇总了C#中ObservableCollection.ToLiveLinq方法的典型用法代码示例。如果您正苦于以下问题:C# ObservableCollection.ToLiveLinq方法的具体用法?C# ObservableCollection.ToLiveLinq怎么用?C# ObservableCollection.ToLiveLinq使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObservableCollection
的用法示例。
在下文中一共展示了ObservableCollection.ToLiveLinq方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SelectThenExcept
public void SelectThenExcept()
{
var coll1 = new ObservableCollection<SelectObservableCollectionViewModel>();
coll1.Add(new SelectObservableCollectionViewModel("test"));
var coll2 = new ObservableCollection<string>(new[] {"test"});
var result1 = coll1.ToLiveLinq().Select(vm => vm.Name.AsObservable()).ToReadOnlyObservableList();
var result2 = result1.ToLiveLinq().Except(coll2.ToLiveLinq()).ToReadOnlyObservableList();
result1.Count.Should().Be(1);
result1[0].Should().Be("test");
result2.Count.Should().Be(0);
coll1[0].Name.Value = "test2";
result1.Count.Should().Be(1);
result1[0].Should().Be("test2");
result2.Count.Should().Be(1);
result2[0].Should().Be("test2");
coll2[0] = "test2";
result1.Count.Should().Be(1);
result1[0].Should().Be("test2");
result2.Count.Should().Be(0);
coll2[0] = "test3";
result1.Count.Should().Be(1);
result1[0].Should().Be("test2");
result2.Count.Should().Be(1);
result2[0].Should().Be("test2");
}
示例2: ObservableCollection_Clear
public void ObservableCollection_Clear()
{
var source = new ObservableCollection<string>() { "A", "B", "C" };
var snapshot = source.ToLiveLinq().ToObservableEnumerable().Snapshot();
source.Clear();
snapshot.Value.Should().BeEmpty();
}
开发者ID:ApocalypticOctopus,项目名称:Apocalyptic.Utilities.Net,代码行数:7,代码来源:ExtensionsTests.StartStopLiveLinq.cs
示例3: ObservableCollection_Add
public void ObservableCollection_Add()
{
var source = new ObservableCollection<string>();
var snapshot = source.ToLiveLinq().ToObservableEnumerable().Snapshot();
source.Add("A");
snapshot.Value.Should().ContainSingle("A");
}
开发者ID:ApocalypticOctopus,项目名称:Apocalyptic.Utilities.Net,代码行数:7,代码来源:ExtensionsTests.StartStopLiveLinq.cs
示例4: ObservableCollection_AddRemove
public void ObservableCollection_AddRemove()
{
var source = new ObservableCollection<string>();
var snapshot = source.ToLiveLinq().ToObservableEnumerable().Snapshot();
source.Add("A");
source.RemoveAt(0);
snapshot.Value.Should().BeEmpty();
}
开发者ID:ApocalypticOctopus,项目名称:Apocalyptic.Utilities.Net,代码行数:8,代码来源:ExtensionsTests.StartStopLiveLinq.cs
示例5: InitialThenChange
public void InitialThenChange()
{
var vm = new SelectObservableCollectionViewModel("test1");
var vms = new ObservableCollection<SelectObservableCollectionViewModel>(new[] { vm });
var result = vms.ToLiveLinq().Select(avm => avm.Name.AsObservable()).ToReadOnlyObservableList();
result[0].Should().Be("test1");
vm.Name.Value = "test2";
result[0].Should().Be("test2");
}
开发者ID:ApocalypticOctopus,项目名称:Apocalyptic.Utilities.Net,代码行数:9,代码来源:SelectObservableCollectionTests.cs
示例6: AddThenChangeIncludeToFalse
public void AddThenChangeIncludeToFalse()
{
var vms = new ObservableCollection<WhereObservableCollectionViewModel>();
var result = vms.ToLiveLinq().Where(vm => vm.Predicate).ToReadOnlyObservableList();
result.Count.Should().Be(0);
vms.Add(new WhereObservableCollectionViewModel(true));
result.Count.Should().Be(1);
vms[0].Predicate.Value = false;
result.Count.Should().Be(0);
}
开发者ID:ApocalypticOctopus,项目名称:Apocalyptic.Utilities.Net,代码行数:10,代码来源:WhereObservableCollectionTests.cs
示例7: ChangeIncludeToTrue
public void ChangeIncludeToTrue()
{
var vms =
new ObservableCollection<WhereObservableCollectionViewModel>(new[]
{new WhereObservableCollectionViewModel(false)});
var result = vms.ToLiveLinq().Where(vm => vm.Predicate).ToReadOnlyObservableList();
result.Count.Should().Be(0);
vms[0].Predicate.Value = true;
result.Count.Should().Be(1);
}
开发者ID:ApocalypticOctopus,项目名称:Apocalyptic.Utilities.Net,代码行数:10,代码来源:WhereObservableCollectionTests.cs
示例8: Remove
public void Remove()
{
var vms = new ObservableCollection<SelectObservableCollectionViewModel>();
var result = vms.ToLiveLinq().Select(vm => vm.Name.AsObservable()).ToReadOnlyObservableList();
result.Count.Should().Be(0);
vms.Add(new SelectObservableCollectionViewModel("test1"));
result.Count.Should().Be(1);
vms.RemoveAt(0);
result.Count.Should().Be(0);
}
开发者ID:ApocalypticOctopus,项目名称:Apocalyptic.Utilities.Net,代码行数:10,代码来源:SelectObservableCollectionTests.cs
示例9: AddThenChange
public void AddThenChange()
{
var vm = new SelectObservableCollectionViewModel("test1");
var vms = new ObservableCollection<SelectObservableCollectionViewModel>();
var result = vms.ToLiveLinq().Select(avm => avm.Name.AsObservable()).ToReadOnlyObservableList();
result.Should().BeEmpty();
vms.Add(vm);
result.Should().BeEquivalentTo("test1");
vm.Name.Value = "test2";
result.Should().BeEquivalentTo("test2");
}
开发者ID:ApocalypticOctopus,项目名称:Apocalyptic.Utilities.Net,代码行数:11,代码来源:SelectObservableCollectionTests.cs
示例10: ToDictionary_Reset
public void ToDictionary_Reset()
{
var source = new ObservableCollection<IKeyValuePair<int, string>>();
var get2 = Nothing<string>();
source.ToLiveLinq().ToLiveLinq()[2].Subscribe(val => get2 = val);
get2.Should().Be(Nothing<string>());
source.Add(KeyValuePair(2, "Hi there"));
get2.Should().Be(Something("Hi there"));
source.RemoveAt(0);
source.Add(KeyValuePair(2, "Hello"));
get2.Should().Be(Something("Hello"));
}
开发者ID:ApocalypticOctopus,项目名称:Apocalyptic.Utilities.Net,代码行数:12,代码来源:DictionaryLiveLinqQueryTests.cs
示例11: RemoveThenChangeIncludeToTrue
public void RemoveThenChangeIncludeToTrue()
{
var vms = new ObservableCollection<WhereObservableCollectionViewModel>();
var result = vms.ToLiveLinq().Where(vm2 => vm2.Predicate).ToReadOnlyObservableList();
result.Count.Should().Be(0);
var vm = new WhereObservableCollectionViewModel(false);
vms.Add(vm);
result.Count.Should().Be(0);
vms.RemoveAt(0);
vm.Predicate.Value = true;
result.Count.Should().Be(0);
}
开发者ID:ApocalypticOctopus,项目名称:Apocalyptic.Utilities.Net,代码行数:12,代码来源:WhereObservableCollectionTests.cs
示例12: SelectTwice
public void SelectTwice()
{
var coll1 = new ObservableCollection<NestedViewModel>();
var result = coll1.ToLiveLinq()
.Select(nested => nested.Property.AsObservable())
.Select(kvp => kvp.Name.AsObservable()).ToReadOnlyObservableList();
result.Count.Should().Be(0);
coll1.Add(new NestedViewModel(new SelectObservableCollectionViewModel("test")));
result.Count.Should().Be(1);
result[0].Should().Be("test");
coll1[0].Property.Value.Name.Value = "test2";
result[0].Should().Be("test2");
}
示例13: SyncTo_RemoveThenChange
public void SyncTo_RemoveThenChange()
{
var vms = new ObservableCollection<SelectObservableCollectionViewModel>();
var result = new List<string>();
vms.ToLiveLinq().Select(vm => vm.Name.AsObservable()).SyncTo(result, false);
result.Count.Should().Be(0);
var tmp = new SelectObservableCollectionViewModel("test1");
vms.Add(tmp);
result.Count.Should().Be(1);
vms.RemoveAt(0);
result.Count.Should().Be(0);
tmp.Name.Value = "test2";
result.Count.Should().Be(0);
}
开发者ID:ApocalypticOctopus,项目名称:Apocalyptic.Utilities.Net,代码行数:14,代码来源:SelectObservableCollectionTests.cs
示例14: SyncTo_AddThenChange
public void SyncTo_AddThenChange()
{
var vm = new SelectObservableCollectionViewModel("test1");
var vms = new ObservableCollection<SelectObservableCollectionViewModel>();
var result = new List<string>();
vms.ToLiveLinq().Select(avm => avm.Name.AsObservable()).SyncTo(result, false);
result.Should().BeEmpty();
vms.Add(vm);
result.Should().BeEquivalentTo("test1");
vm.Name.Value = "test2";
result.Should().BeEquivalentTo("test2");
}
开发者ID:ApocalypticOctopus,项目名称:Apocalyptic.Utilities.Net,代码行数:12,代码来源:SelectObservableCollectionTests.cs
示例15: SyncTo_InitialThenChange
public void SyncTo_InitialThenChange()
{
var vm = new SelectObservableCollectionViewModel("test1");
var vms = new ObservableCollection<SelectObservableCollectionViewModel>(new[] { vm });
var result = new List<string>();
vms.ToLiveLinq().Select(avm => avm.Name.AsObservable()).SyncTo(result, false);
result[0].Should().Be("test1");
vm.Name.Value = "test2";
result[0].Should().Be("test2");
}
开发者ID:ApocalypticOctopus,项目名称:Apocalyptic.Utilities.Net,代码行数:10,代码来源:SelectObservableCollectionTests.cs