示例#1
0
文件: p157.cs 项目: snvkdnsem/Csharp
 public event MyEventHandler MyEvent; //이벤트 정의
 public void Do()
 {
     //이벤트 가입자가 있는지 확인
     if (MyEvent != null)
     {
         EventPublisherArgs args = new EventPublisherArgs("데이터");
         MyEvent(this, args); //이벤트 발생
     }
 }
示例#2
0
        /// <summary>
        /// Creates an event publisher.
        /// </summary>
        /// <returns></returns>
        public IEventPublisher CreatePublisher(EventPublisherArgs eventPublisherArgs)
        {
            // construct the publisher
            var mqEventPublisher = new MsmqEventPublisher(
                string.Format("{0}_{1}", _mqBasePath, Interlocked.Increment(ref _mqCounter)));

            // connect the statement to the publisher
            eventPublisherArgs.Statement.Events += (sender, eventArgs) => mqEventPublisher.SendEvent(eventArgs);
            // return the publisher
            return(mqEventPublisher);
        }
 /// <summary>
 /// Creates an event publisher.
 /// </summary>
 /// <returns></returns>
 public IEventPublisher CreatePublisher(EventPublisherArgs eventPublisherArgs)
 {
     // construct the exchange name
     var publisherTopic = CreatePublisherTopic();
     // construct the publication address
     var publicationAddress = new PublicationAddress(
         ExchangeType.Topic, _exchangePath, publisherTopic);
     // construct the publisher
     var eventPublisher = new RabbitMqEventPublisher(_model, _exchangeAddr, publicationAddress);
     // connect the statement to the publisher
     eventPublisherArgs.Statement.Events += (sender, eventArgs) => eventPublisher.SendEvent(eventArgs);
     // return the publisher
     return eventPublisher;
 }
        /// <summary>
        /// Creates an event publisher.
        /// </summary>
        /// <returns></returns>
        public IEventPublisher CreatePublisher(EventPublisherArgs eventPublisherArgs)
        {
            // construct the exchange name
            var publisherTopic = CreatePublisherTopic();
            // construct the publication address
            var publicationAddress = new PublicationAddress(
                ExchangeType.Topic, _exchangePath, publisherTopic);
            // construct the publisher
            var eventPublisher = new RabbitMqEventPublisher(_model, _exchangeAddr, publicationAddress);

            // connect the statement to the publisher
            eventPublisherArgs.Statement.Events += (sender, eventArgs) => eventPublisher.SendEvent(eventArgs);
            // return the publisher
            return(eventPublisher);
        }