private static void OnReceiveComplete(IAsyncResult ar) { FeedAsyncResult result = ar as FeedAsyncResult; FeedInputChannel channel = result.Channel; Feed feed = channel.EndReceive(result); if (FeedEngine.FeedReceived != null) { FeedEngine.FeedReceived(feed); } if (receivers.Count > 0) { FeedReceiver receiver = receivers[channel.Destination] as FeedReceiver; if (receiver != null) { receiver.Receive(feed); } } // Update the storage if (Storage != null) { Storage.Add(feed); } }
/// <summary> /// Subscribes to a RSS feed /// </summary> /// <param name="destination">The Uri destination object.</param> /// <param name="receiver">The FeedReceiver that will receive the RSS feed.</param> public static void Subscribe(Uri destination, FeedReceiver receiver) { if (destination == null) { throw new ArgumentNullException("destination"); } if (receiver == null) { throw new ArgumentNullException("receiver"); } IFeedInputChannel channel = null; if (channels[destination] == null) { channel = FeedTransport.StaticGetInputChannel(destination); if (channel != null) { channels.Add(destination, channel); receivers.Add(destination, receiver); feedWorker.AddFeed(destination); } } else { channel = channels[destination] as IFeedInputChannel; } channel.BeginReceive(new AsyncCallback(FeedEngine.OnReceiveComplete), destination); }
private static void OnReceive(Uri destination) { FeedReceiver receiver = receivers[destination] as FeedReceiver; FeedEngine.Subscribe(destination, receiver); }