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


C# Subject.OfType方法代码示例

本文整理汇总了C#中Subject.OfType方法的典型用法代码示例。如果您正苦于以下问题:C# Subject.OfType方法的具体用法?C# Subject.OfType怎么用?C# Subject.OfType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Subject的用法示例。


在下文中一共展示了Subject.OfType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OfType

        public void OfType()
        {
            var subject = new Subject<object>();

            var list = new List<int>();
            subject.OfType(default(int)).Subscribe(x => list.Add(x));

            subject.OnNext(1);
            subject.OnNext(2);
            subject.OnNext("hogehoge");
            subject.OnNext(3);

            list.IsCollection(1, 2, 3);
        }
开发者ID:createdbyx,项目名称:UniRx,代码行数:14,代码来源:ConversionTest.cs

示例2: OfType

 public void OfType()
 {
     SetScehdulerForImport();
     var subject = new Subject<object>();
     var list = new List<int>();
     subject.OfType(default(int)).Subscribe(x => list.Add(x));
     subject.OnNext(1);
     subject.OnNext(2);
     subject.OnNext("hogehoge");
     subject.OnNext(3);
     list.IsCollection(1, 2, 3);
     UniRx.Scheduler.SetDefaultForUnity();
 }
开发者ID:neuecc,项目名称:UniRx,代码行数:13,代码来源:TestImporter.cs

示例3: TestConfiguration

        static void TestConfiguration(Action<CqrsEngineBuilder> build, int useMessages)
        {
            var builder = new CqrsEngineBuilder();
            build(builder);

            var subj = new Subject<ISystemEvent>();

            builder.Advanced.Observers.Clear();
            builder.Advanced.RegisterObserver(subj);

            var step = (useMessages / 5);
            int count = 0;
            var watch = new Stopwatch();
            using (var token = new CancellationTokenSource())
            {
                subj
                    .OfType<EnvelopeAcked>()
                    .Subscribe(ea =>
                        {
                            count += 1;

                            if ((count % step) == 0)
                            {
                                var messagesPerSecond = count / watch.Elapsed.TotalSeconds;
                                Console.WriteLine("{0} - {1}", count, Math.Round(messagesPerSecond, 1));
                            }

                            if (ea.Attributes.Any(ia => ia.Key == "last"))
                            {
                                token.Cancel();
                            }
                        });

                using (var engine = builder.Build())
                {
                    // first we send X then we check
                    var sender = engine.Resolve<IMessageSender>();

                    for (int i = 0; i < useMessages; i++)
                    {
                        sender.SendOne(new UsualMessage { HasData = true });
                    }
                    sender.SendOne(new UsualMessage { HasData = true}, b => b.AddString("last"));

                    watch.Start();
                    engine.Start(token.Token);
                    token.Token.WaitHandle.WaitOne(10000);
                }
            }
        }
开发者ID:higheredgrowth,项目名称:lokad-cqrs,代码行数:50,代码来源:Performance_tests_for_throughput.cs


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