/// <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); }
/// <summary> /// Loads feed serializer /// </summary> /// <param name="typeName">Type name of serializer</param> /// <returns>Feed serializer object.</returns> public static IFeedSerializer LoadSerializer(string typeName) { Type type = Type.GetType(typeName, false); if (type != null) { return(FeedTransport.LoadSerializer(type)); } return(null); }
/// <summary> /// Gets the input channel for the transport. /// </summary> /// <param name="destination">The Uri to receive the RSS feeds.</param> /// <returns>The IFeedInputChannel associated with the transport. </returns> public static IFeedInputChannel StaticGetInputChannel(Uri destination) { IFeedTransport transport = FeedTransport.GetTransport(destination); if (transport != null) { return(transport.GetInputChannel(destination)); } return(null); }
/// <summary> /// /// </summary> /// <param name="destination"></param> /// <returns></returns> public static Feed Receive(Uri destination) { if (destination == null) { throw new ArgumentNullException(); } IFeedInputChannel channel = FeedTransport.StaticGetInputChannel(destination); return(channel.Receive()); }
/// <summary> /// Subscribes to a RSS feed. /// </summary> /// <param name="destination">The Uri destination object.</param> public static void Subscribe(Uri destination) { if (destination == null) { throw new ArgumentNullException(); } IFeedInputChannel channel = null; if (channels[destination] == null) { channel = FeedTransport.StaticGetInputChannel(destination); if (channel != null) { channels.Add(destination, channel); feedWorker.AddFeed(destination); } } else { channel = channels[destination] as IFeedInputChannel; } }
public FeedHttpTransport(XmlNodeList configData) { this.connections = new Hashtable(); this.defaulPort = 80; this.outboundLimit = 16; this.receiveTimeout = 10000; if (configData != null) { foreach (XmlNode node in configData) { XmlElement element = node as XmlElement; if (element != null) { switch (element.LocalName) { case "connectionLimit": { int outLimit = Convert.ToInt32(element.Attributes["inbound"].Value); //int inLimit = Convert.ToInt32(element.Attributes["outbound"].Value); this.outboundLimit = outLimit; //this.inboundLimit = inLimit; continue; } case "defaultPort": { this.defaulPort = Convert.ToInt32(element.Attributes["value"].Value); continue; } case "serializer": { string serializerType = element.Attributes["type"].Value; this.serializer = FeedTransport.LoadSerializer(serializerType); continue; } case "hosts": { //this.ParseHosts(element); continue; } case "receiveTimeout": { this.receiveTimeout = Convert.ToInt32(element.Attributes["value"].Value); continue; } //case "sendTimeout": // { // this.sendTimeout = Convert.ToInt32(element.Attributes["value"].Value); // continue; // } } } } } if (this.serializer == null) { this.serializer = new FeedSerializer(); } }