本文整理汇总了C#中IBus.Subscribe方法的典型用法代码示例。如果您正苦于以下问题:C# IBus.Subscribe方法的具体用法?C# IBus.Subscribe怎么用?C# IBus.Subscribe使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IBus
的用法示例。
在下文中一共展示了IBus.Subscribe方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
public void Run(IBus bus, TextWriter w)
{
c.Add(bus.Subscribe<MessageA>(onMessageA));
c.Add(bus.Subscribe<MessageB>(onMessageB));
c.Add(bus.Subscribe<MessageC>(onMessageC));
var r = new Random();
var dict = new Dictionary<int, Func<object>>
{
{0, () => new MessageA()},
{1, () => new MessageB()},
{2, () => new MessageC()},
};
int count = 0;
var sw = Stopwatch.StartNew();
while (count < 100000)
{
bus.Publish(dict[r.Next(0, 3)]());
count++;
}
w.WriteLine("Through {0}", sw.ElapsedMilliseconds);
count = 0;
while (count < 10)
{
w.WriteLine("From MsgA:{0}({1}), B:{2}({3}), C:{4}({5})", aCount, MessageA.Count, bCount,
MessageB.Count, cCount, MessageC.Count);
Thread.Sleep(1000);
count++;
}
}
示例2: Run
public void Run(IBus bus, TextWriter w)
{
_c.Add(bus.Subscribe<MessageA>(OnMessageA));
_c.Add(bus.Subscribe<MessageB>(OnMessageB));
_c.Add(bus.Subscribe<MessageC>(OnMessageC));
var r = new Random();
var dict = new Dictionary<int, Func<object>>
{
{0, () => new MessageA()},
{1, () => new MessageB()},
{2, () => new MessageC()},
};
int count = 0;
var sw = Stopwatch.StartNew();
while (count < 100000)
{
bus.Publish(dict[r.Next(0, 3)]());
count++;
}
w.WriteLine("Through {0}", sw.ElapsedMilliseconds);
while (_aCount != MessageA.Count && _bCount != MessageB.Count && _cCount != MessageC.Count)
{
WriteInfo(w);
Thread.Sleep(1000);
}
WriteInfo(w);
}
示例3: SetupQuoteClient
protected void SetupQuoteClient()
{
if (QuoteClientEnabled)
{
Bus = RabbitHutch.CreateBus(QuoteClientConnectionString);
string instrumentSymbol = Instrument.Symbol.ToUpperInvariant();
CurrentQuoteClientSubscription = string.Format(
"{0}.{1}.{2}",
EnvironmentManager.GetNormalizedMachineName(),
ProjectName,
instrumentSymbol)
.ToUpperInvariant()
.Replace("-", "")
.Replace("_", "");
LoggingUtility.WriteInfoFormat(this, "ENABLING quote client with sub id: {0}",
CurrentQuoteClientSubscription);
Bus.Subscribe<OnBarOpenMessage>(CurrentQuoteClientSubscription, HandleOnBarOpenFromBus,
x => x.WithTopic(instrumentSymbol));
Bus.Subscribe<OnBarMessage>(CurrentQuoteClientSubscription, HandleOnBarFromBus,
x => x.WithTopic(instrumentSymbol));
Bus.Subscribe<OnQuoteMessage>(CurrentQuoteClientSubscription, HandleOnQuoteFromBus,
x => x.WithTopic(instrumentSymbol));
NumberOfQuotes = 0;
QuoteClientStartAt = DateTime.Now;
}
else
{
LoggingUtility.WriteInfo(this, "Quote client is NOT ENABLED");
}
}
示例4: Subscribe
public static void Subscribe(IBus bus, HttpService service)
{
bus.Subscribe<SystemMessage.SystemInit>(service);
bus.Subscribe<SystemMessage.BecomeShuttingDown>(service);
bus.Subscribe<HttpMessage.SendOverHttp>(service);
bus.Subscribe<HttpMessage.UpdatePendingRequests>(service);
}
示例5: ClickMarker
public ClickMarker(SceneNode marker, IBus bus)
{
m_Marker = marker;
m_Bus = bus;
m_Disposer = new Disposer();
m_Bus.Subscribe<SetPathToTargetMessage>(MoveMarker).AddTo(m_Disposer);
m_Bus.Subscribe<SelectObjectAtMessage>(MoveMarker).AddTo(m_Disposer);
}
示例6: Scene
public Scene(IBus bus, SceneManager sceneManager)
{
m_Bus = bus;
m_SceneManager = sceneManager;
m_SceneNodes = new List<NodeWithPosition>();
m_Disposer = new Disposer();
m_Bus.Subscribe<PathMessage>(UpdateMotion).AddTo(m_Disposer);
m_Bus.Subscribe<SelectedObjectMessage>(OnSelected).AddTo(m_Disposer);
m_Bus.Subscribe<DeselectedObjectMessage>(OnDeselected).AddTo(m_Disposer);
}
示例7: Unexpected_Disposal_Of_Subscriptions
public Unexpected_Disposal_Of_Subscriptions()
{
_bus = BusSetup.StartWith<Conservative>()
.Apply<FlexibleSubscribeAdapter>(adp => adp.RegisterMethods("Handle"))
.Construct();
_bus.Subscribe(_partnerInCrime1 = new Subscriber());
_bus.Subscribe(_partnerInCrime2 = new Subscriber());
// One disposes the other. That way we keep independent of call sequence
_partnerInCrime1.Aquaint(_partnerInCrime2);
_partnerInCrime2.Aquaint(_partnerInCrime1);
}
示例8: WhenSendingMessages
public void WhenSendingMessages()
{
var c1 = new FakeConsumer<TestMessages.ADerivedTestMessage> (msg => Consumer1(msg));
var c2 = new FakeConsumer<TestMessages.TestMessage> (msg => Consumer2(msg));
var c3 = new FakeConsumer<IMessage> (msg => Consumer3(msg));
_bus = new Bus ();
_bus.Subscribe (c1);
_bus.Subscribe (c2);
_bus.Subscribe (c3);
RunAsync ();
}
示例9: ProgressManager
public ProgressManager (IBus bus, IDownloadRepository repo)
{
_progresses = new ConcurrentDictionary<string, Progress> ();
_notificationqueue = new ConcurrentDictionary<string, Download> ();
_repository = repo;
_bus = bus;
_bus.Subscribe<NotifyGlobalProgress> (NotifyGlobalProgress);
_bus.Subscribe<NotifyProgress> (NotifyProgress);
_bus.Subscribe<ResetDownloads> (ResetDownloads);
_bus.Subscribe<ThrottleNotifyProgress> (ThrottleNotifyProgress);
}
示例10: WhenSendingMessages
public void WhenSendingMessages()
{
var c1 = new FakeConsumer<TestMessages.ADerivedTestMessage> (msg => Consumer1(msg));
var c2 = new FakeConsumer<TestMessages.TestMessage> (msg => Consumer2(msg));
var c3 = new FakeConsumer<IMessage> (msg => Consumer3(msg));
_bus = new Bus.Bus ();
_bus.Subscribe (c1);
_bus.Subscribe (c2);
_bus.Subscribe (c3);
for (int i = 0; i < _numberOfMessagesToSend; i++) {
_bus.Send (new TestMessages.ADerivedTestMessage{ Id = "P1-" + i });
}
}
示例11: SubscribeAllEventsFromAssembly
private static void SubscribeAllEventsFromAssembly(IBus bus, Assembly assembly)
{
foreach (var type in assembly.GetTypes().Where(t => true /* Use here your conventions to detect events */))
{
bus.Subscribe(type);
}
}
示例12: Main
static void Main(string[] args)
{
bus = new AzureBus();
bus.Subscribe<SendSms>("SmsReceiverService", sendSmsHandler);
string input = string.Empty;
Console.WriteLine("Ready...");
Console.WriteLine();
do
{
input = Console.ReadLine();
if (input.StartsWith("!"))
{
ParseCommand(input);
}
else
{
SendSms(input);
}
} while (input != "!QUIT");
}
示例13: MainWindowViewModel
public MainWindowViewModel(IBus bus)
{
_bus = bus;
_bus.Subscribe<EasyMsg>(_appId, HandleStringMsg);
SubcriptionLog = "Listening";
SendMessage = new RelayCommand(SendNewMessage);
WindowTitle = "App: " + _appId;
}
示例14: SelectableObjectRepository
public SelectableObjectRepository(IBus bus,
IPlayerId id,
IVesselRepository vesselRepository)
{
m_Bus = bus;
m_Id = id;
m_VesselRepository = vesselRepository;
m_Objects = new List< SelectableObject>();
m_Disposer = new Disposer();
m_Bus.Subscribe<SelectObjectAtMessage>(OnSelectObject).AddTo(m_Disposer);
m_Bus.Subscribe<RequestPathMessage>(OnPathRequest).AddTo(m_Disposer);
m_Bus.Subscribe<SetPathToTargetMessage>(OnSetPath).AddTo(m_Disposer);
}
示例15: WhenSendingMessages
public void WhenSendingMessages()
{
var consumer = new FakeConsumer<TestMessages.ADerivedTestMessage> (msg => HandleReceived(msg));
_bus = new Bus.Bus ();
_bus.Subscribe (consumer);
RunAsync ();
}