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


C# IBus.Subscribe方法代码示例

本文整理汇总了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++;
            }
        }
开发者ID:pixelmeister,项目名称:MemBus,代码行数:32,代码来源:Simple.cs

示例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);
        }
开发者ID:mdabbagh88,项目名称:MemBus,代码行数:30,代码来源:Simple.cs

示例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");
            }
        }
开发者ID:aggarwalmanuj,项目名称:open-quant,代码行数:35,代码来源:BaseStrategy.QuoteClient.cs

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

示例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);
        }
开发者ID:anthony-martin,项目名称:Triangles-in-space,代码行数:9,代码来源:ClickMarker.cs

示例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);
        }
开发者ID:anthony-martin,项目名称:Triangles-in-space,代码行数:11,代码来源:Scene.cs

示例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);
        }
开发者ID:flq,项目名称:MemBus,代码行数:12,代码来源:Unexpected_disposal_of_subscriptions.cs

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

示例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);

		}
开发者ID:lduchosal,项目名称:DownloadManager.Xamarin,代码行数:13,代码来源:ProgressManager.cs

示例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 });
            }
        }
开发者ID:rmacdonaldsmith,项目名称:MiniVan,代码行数:15,代码来源:OneProducerThreeConsumers.cs

示例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);
     }
 }
开发者ID:modulexcite,项目名称:NServiceBus.Bridge.ActiveMQ,代码行数:7,代码来源:MsmqEventRegistration.cs

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

示例13: MainWindowViewModel

 public MainWindowViewModel(IBus bus)
 {
     _bus = bus;
     _bus.Subscribe<EasyMsg>(_appId, HandleStringMsg);
     SubcriptionLog = "Listening";
     SendMessage = new RelayCommand(SendNewMessage);
     WindowTitle = "App: " + _appId;
 }
开发者ID:pdoh00,项目名称:RabbitMQ_Test,代码行数:8,代码来源:MainWindowViewModel.cs

示例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);
        }
开发者ID:anthony-martin,项目名称:Triangles-in-space,代码行数:17,代码来源:SelectableObjectRepository.cs

示例15: WhenSendingMessages

        public void WhenSendingMessages()
        {
            var consumer = new FakeConsumer<TestMessages.ADerivedTestMessage> (msg => HandleReceived(msg));
            _bus = new Bus.Bus ();
            _bus.Subscribe (consumer);

            RunAsync ();
        }
开发者ID:rmacdonaldsmith,项目名称:MiniVan,代码行数:8,代码来源:ThreeProducersOneConsumer.cs


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