本文整理汇总了C#中Subject.Distinct方法的典型用法代码示例。如果您正苦于以下问题:C# Subject.Distinct方法的具体用法?C# Subject.Distinct怎么用?C# Subject.Distinct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Subject
的用法示例。
在下文中一共展示了Subject.Distinct方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Distinct
public void Distinct()
{
{
var subject = new Subject<int>();
int[] array = null;
var disp = subject.Distinct().ToArray().Subscribe(xs => array = xs);
Array.ForEach(new[] { 1, 10, 10, 1, 100, 100, 100, 5, 70, 7 }, subject.OnNext);
subject.OnCompleted();
array.Is(1, 10, 100, 5, 70, 7);
}
{
var subject = new Subject<int>();
int[] array = null;
var disp = subject.Distinct(x => x, EqualityComparer<int>.Default).ToArray().Subscribe(xs => array = xs);
Array.ForEach(new[] { 1, 10, 10, 1, 100, 100, 100, 5, 70, 7 }, subject.OnNext);
subject.OnCompleted();
array.Is(1, 10, 100, 5, 70, 7);
}
}
示例2: Run
public static void Run()
{
{
var subject = new Subject<int>();
var distinct = subject.Distinct();
subject.Subscribe(
i => Console.WriteLine("{0}", i),
() => Console.WriteLine("subject.OnCompleted()"));
distinct.Subscribe(
i => Console.WriteLine("distinct.OnNext{0}", i),
() => Console.WriteLine("distinct..OnCompleted()"));
subject.OnNext(1);
subject.OnNext(2);
subject.OnNext(3);
subject.OnNext(1);
subject.OnNext(1);
subject.OnNext(4);
subject.OnCompleted();
}
{
var subject = new Subject<int>();
var distinct = subject.DistinctUntilChanged();
subject.Subscribe(
i => Console.WriteLine("{0}", i),
() => Console.WriteLine("subject.OnCompleted()"));
distinct.Subscribe(
i => Console.WriteLine("distinct.OnNext{0}", i),
() => Console.WriteLine("distinct..OnCompleted()"));
subject.OnNext(1);
subject.OnNext(2);
subject.OnNext(3);
subject.OnNext(1);
subject.OnNext(1);
subject.OnNext(4);
subject.OnCompleted();
}
}
示例3: Run_Distinct
public void Run_Distinct()
{
ConsoleUtility.PrintSuccess(string.Format("Distinct example"));
var subject = new Subject<int>();
var distinct = subject.Distinct();
subject.Subscribe(
i => Console.WriteLine("{0}", i),
() => Console.WriteLine("subject.OnCompleted()"));
distinct.Subscribe(
i => Console.WriteLine("distinct.OnNext({0})", i),
() => Console.WriteLine("distinct.OnCompleted()"));
subject.OnNext(1);
subject.OnNext(2);
subject.OnNext(3);
subject.OnNext(3);
subject.OnNext(3);
subject.OnNext(1);
subject.OnNext(1);
subject.OnNext(4);
subject.OnCompleted();
}
示例4: Distinct
public void Distinct()
{
{
var subject = new Subject<int>();
int[] array = null;
subject.Distinct().ToArray().Subscribe(xs => array = xs);
foreach (var item in new[] { 1, 10, 10, 1, 100, 100, 100, 5, 70, 7 }) { subject.OnNext(item); };
subject.OnCompleted();
array.IsCollection(1, 10, 100, 5, 70, 7);
}
{
var subject = new Subject<int>();
int[] array = null;
subject.Distinct(x => x, EqualityComparer<int>.Default).ToArray().Subscribe(xs => array = xs);
foreach (var item in new[] { 1, 10, 10, 1, 100, 100, 100, 5, 70, 7 }) { subject.OnNext(item); };
subject.OnCompleted();
array.IsCollection(1, 10, 100, 5, 70, 7);
}
}