/// <summary>
        /// Override this method to handle an offline announcement message.
        /// </summary>
        /// <param name="messageSequence">The discovery message sequence.</param>
        /// <param name="endpointDiscoveryMetadata">The endpoint discovery metadata.</param>
        /// <param name="callback">The callback delegate to call when the operation is completed.</param>
        /// <param name="state">The user-defined state data.</param>
        /// <returns>
        /// A reference to the pending asynchronous operation.
        /// </returns>
        protected override IAsyncResult OnBeginOfflineAnnouncement(DiscoveryMessageSequence messageSequence, EndpointDiscoveryMetadata endpointDiscoveryMetadata, AsyncCallback callback, object state)
        {
            if (endpointDiscoveryMetadata == null)
            {
                throw new ArgumentNullException("endpointDiscoveryMetadata");
            }

            FindCriteria criteria = new FindCriteria(typeof(T));

            if (criteria.IsMatch(endpointDiscoveryMetadata))
            {
                // 指定类型的服务下线
                if (cache.Contains(endpointDiscoveryMetadata.Address.Uri))
                {
                    cache.Remove(endpointDiscoveryMetadata);
                    Console.WriteLine(string.Format(CultureInfo.InvariantCulture, "Discovery proxy endpoint offline : {0} - {1}", endpointDiscoveryMetadata.GetSpecifiedName(), endpointDiscoveryMetadata.Address.Uri));
                }
            }

            return(new CompletedAsyncResult(callback, state));
        }
        private void OnOfflineAnnouncement(object sender, AnnouncementEventArgs e)
        {
            EndpointDiscoveryMetadata metadata = e.EndpointDiscoveryMetadata;

            FindCriteria criteria = new FindCriteria(typeof(T));

            if (criteria.IsMatch(metadata))
            {
                // 指定类型的服务下线
                if (cache.Contains(metadata.Address.Uri))
                {
                    cache.Remove(metadata);
                    Console.WriteLine(string.Format(CultureInfo.InvariantCulture, "Announcement endpoint offline : {0} - {1}", metadata.GetSpecifiedName(), metadata.Address.Uri));
                }
            }
        }