コード例 #1
0
ファイル: EventTopic.cs プロジェクト: wuyingyou/uniframework
 internal void Fire(Publication publication, object sender, EventArgs e)
 {
     WorkItem workItem = publication.WorkItem;
     if (workItem == null || (workItem != null && workItem.Status == WorkItemStatus.Terminated))
     {
         publications.Remove(publication);
         publication.Dispose();
     }
     else
     {
         Fire(sender, e, publication.WorkItem, publication.Scope);
     }
 }
コード例 #2
0
ファイル: EventTopic.cs プロジェクト: wuyingyou/uniframework
        /// <summary>
        /// Adds a publication to the topic.
        /// </summary>
        /// <param name="publisher">The object that publishes the event that will fire the topic.</param>
        /// <param name="eventName">The name of the event.</param>
        /// <param name="workItem">The <see cref="WorkItem"/> where the publisher is.</param>
        /// <param name="scope">A <see cref="PublicationScope"/> value which states scope for the publication.</param>
        public virtual void AddPublication(object publisher, string eventName, WorkItem workItem, PublicationScope scope)
        {
            Guard.ArgumentNotNull(publisher, "publisher");
            Guard.ArgumentNotNullOrEmptyString(eventName, "eventName");
            Guard.ArgumentNotNull(workItem, "workItem");
            Guard.EnumValueIsDefined(typeof(PublicationScope), scope, "scope");
            Clean();
            ThrowIfRepeatedPublication(publisher, eventName);

            Publication publication = new Publication(this, publisher, eventName, workItem, scope);

            publications.Add(publication);

            if (traceSource != null)
                traceSource.TraceInformation(Properties.Resources.EventTopicTracePublicationAdded,
                    name, eventName, publisher.GetType().ToString());
        }