Skip to content

Instantly share code, notes, and snippets.

View RolandPheasant's full-sized avatar
💭
In the mountains for a week,

Roland Pheasant RolandPheasant

💭
In the mountains for a week,
View GitHub Profile
@RolandPheasant
RolandPheasant / MySourceList.cs
Created February 8, 2022 17:08
How to implement ICollection and ISourceList
public class MySourceList<T>: ISourceList<T>, ICollection<T>
{
private readonly ISourceList<T> _innerList;
public MySourceList()
{
_innerList = new SourceList<T>();
}
public int Count => _innerList.Count;
using DynamicData;
using DynamicData.Binding;
using ReactiveUI;
using ReactiveUI_GroupingIssueTest_Wpf.Enums;
using ReactiveUI_GroupingIssueTest_Wpf.Models;
using System;
using System.Collections.ObjectModel;
using System.Linq;
using System.Reactive.Linq;
using System;
using DynamicData.Cache.Internal;
namespace DynamicData.Binding
{
public class MyObservableCollectionAdaptor<TObject, TKey> : IObservableCollectionAdaptor<TObject, TKey>
where TKey : notnull
{
private readonly Cache<TObject, TKey> _cache = new();
@RolandPheasant
RolandPheasant / RightJoinWithDeferredLoadFixture.cs
Last active January 7, 2022 16:08
RightJoin / AutoRefresh
using System;
using System.Reactive;
using System.Reactive.Concurrency;
using System.Collections.Generic;
using DynamicData.Binding;
using DynamicData.Kernel;
using FluentAssertions;
using Microsoft.Reactive.Testing;
using Xunit;
@RolandPheasant
RolandPheasant / AutoRefreshBuffered.cs
Created December 7, 2021 19:24
Auto Refresh With Change Set Buffer
public class MyObject : AbstractNotifyPropertyChanged
{
private bool _isSelected;
public int Id { get; set ; }
public bool IsSelected
{
get => _isSelected;
set => SetAndRaise(ref _isSelected, value);
}
using System;
using System.Collections.ObjectModel;
using System.Reactive;
using System.Reactive.Linq;
using DynamicData.Binding;
namespace DynamicData.Tests
{
public class DeepNested
{
var initialItems = Enumerable.Range(1, 5_000)
.Select(i => new SelectableItem(i){IsSelected = true})
.ToArray();
var source = new SourceList<SelectableItem>();
var filtered = source.Connect()
.AutoRefresh(si=>si.IsSelected)
.Filter(si => si.IsSelected)
.Subscribe(_=> Console.WriteLine("got initial data"));
using System;
using System.Collections.Generic;
using ReactiveUI;
using ReactiveUI.Fody.Helpers;
namespace WpfApp1
{
public class TestViewModel : ReactiveObject, IEquatable<TestViewModel>
{
public TestViewModel(int ModelId, bool IsArchived)
@RolandPheasant
RolandPheasant / EnsureUniqueChanges.cs
Last active October 7, 2020 17:56
Unique changes
public static class ChangeSetEx
{
public static IObservable<IChangeSet<TObject, TKey>> EnsureUniqueChanges<TObject, TKey>(this IObservable<IChangeSet<TObject, TKey>> source)
{
return source.Select(EnsureUniqueChanges);
}
public static IChangeSet<TObject, TKey> EnsureUniqueChanges<TObject, TKey>(this IChangeSet<TObject, TKey> input)
{
var changes = input
public class Person : IEquatable<Person>
{
public string UID { get; set; } = Guid.NewGuid().ToString();
public string Name { get; set; }
public string Surname { get; set; }
public int Age { get; set; }
public bool Equals(Person other)