当前位置: 首页>>代码示例>>C#>>正文


C# Subject.Distinct方法代码示例

本文整理汇总了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);
            }
        }
开发者ID:nicecapj,项目名称:UniRx,代码行数:25,代码来源:ObservableTest.cs

示例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();
              }
        }
开发者ID:pudae,项目名称:lplpl,代码行数:44,代码来源:TestDistinct.cs

示例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();
        }
开发者ID:sam-io,项目名称:dotnet-playground,代码行数:22,代码来源:Rx_seq_2_Distinct.cs

示例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);
            }
        }
开发者ID:ragcat,项目名称:UniRx,代码行数:25,代码来源:UnitTests.cs


注:本文中的Subject.Distinct方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。