本文整理汇总了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);
}
示例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();
}
示例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);
}
}
}