Пример #1
0
 /// <summary>
 /// Unregisters the news channel.
 /// </summary>
 /// <param name="channel">The channel.</param>
 public void UnregisterNewsChannel(INewsChannel channel)
 {
     if (channel == null)
     {
         throw new ArgumentNullException("channel");
     }
     if (channel.ChannelProcessingType == ChannelProcessingType.NewsItem)
     {
         try {
             _newsItemChannelsLock.AcquireWriterLock(0);
             try {
                 if (_newsItemChannels.ContainsKey(channel))
                 {
                     _newsItemChannels.Remove(channel);
                 }
             } finally {
                 _newsItemChannelsLock.ReleaseWriterLock();
             }
         } catch (ApplicationException) {
             // lock timeout
         }
     }
     else if (channel.ChannelProcessingType == ChannelProcessingType.Feed)
     {
         try {
             _feedChannelsLock.AcquireWriterLock(0);
             try {
                 if (_feedChannels.ContainsKey(channel))
                 {
                     _feedChannels.Remove(channel);
                 }
             } finally {
                 _feedChannelsLock.ReleaseWriterLock();
             }
         } catch (ApplicationException) {
             // lock timeout
         }
     }
     else
     {
         throw new NotSupportedException("The channel processing type is not yet supported.");
     }
 }
Пример #2
0
            public int Compare(object x, object y)
            {
                INewsChannel lhsX = x as INewsChannel;
                INewsChannel rhsY = y as INewsChannel;

                if (lhsX == null || rhsY == null)                   // We only know how to sort INewsChannel, so return equal
                {
                    return(0);
                }

                if (Object.ReferenceEquals(lhsX, rhsY))
                {
                    return(0);
                }

                if (lhsX.ChannelPriority == rhsY.ChannelPriority)
                {
                    return(String.Compare(lhsX.ChannelName, rhsY.ChannelName));
                }

                return(lhsX.ChannelPriority < rhsY.ChannelPriority ? -1: 1);
            }