///////////////////////////////////////////////////////////////////////////// #endregion /// <summary> /// Parses the inner state of the element /// </summary> /// <param name="e">The extension element that should be added to this entry</param> /// <param name="parser">The AtomFeedParser that called this</param> public virtual void Parse(ExtensionElementEventArgs e, AtomFeedParser parser) { if (e == null) { throw new ArgumentNullException("e"); } //Tracing.TraceMsg("Entering Parse on AbstractEntry"); XmlNode node = e.ExtensionElement; if (this.ExtensionFactories != null && this.ExtensionFactories.Count > 0) { //Tracing.TraceMsg("Entring default Parsing for AbstractEntry"); IExtensionElementFactory f = FindExtensionFactory(node.LocalName, node.NamespaceURI); if (f != null) { this.ExtensionElements.Add(f.CreateInstance(node, parser)); e.DiscardEntry = true; } } return; }
///////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// /// <summary>eventfiring helper for new extensions</summary> /// <param name="node"> the new node that was found</param> /// <param name="baseObject"> the object this node should be added to</param> ////////////////////////////////////////////////////////////////////// protected void OnNewExtensionElement(XmlNode node, AtomBase baseObject) { ExtensionElementEventArgs args = new ExtensionElementEventArgs(); args.ExtensionElement = node; args.Base = baseObject; if (this.NewExtensionElement != null) { this.NewExtensionElement(this, args); } if (args.DiscardEntry == false) { baseObject.ExtensionElements.Add(new XmlExtension(node)); } }
///////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// /// <summary>Event chaining. We catch this by the baseFeedParsers, which /// would not do anything with the gathered data. We pass the event up /// to the user; if the user doesn't discard it, we add the entry to our /// collection</summary> /// <param name="sender"> the object which send the event</param> /// <param name="e">FeedParserEventArguments, holds the feed entry</param> /// <returns> </returns> ////////////////////////////////////////////////////////////////////// protected void OnNewExtensionElement(object sender, ExtensionElementEventArgs e) { // by default, if our event chain is not hooked, the underlying parser will add it //Tracing.TraceCall("received new extension element notification"); //Tracing.Assert(e != null, "e should not be null"); if (e == null) { throw new ArgumentNullException("e"); } if (this.NewExtensionElement != null) { //Tracing.TraceMsg("\t calling event dispatcher"); this.NewExtensionElement(sender, e); } }
/// <summary>eventhandler - called for event extension element /// </summary> /// <param name="sender">the object which send the event</param> /// <param name="e">FeedParserEventArguments, holds the feedEntry</param> /// <returns> </returns> protected void OnNewExtensionsElement(object sender, ExtensionElementEventArgs e) { if (e == null) { throw new ArgumentNullException("e"); } AtomFeedParser parser = sender as AtomFeedParser; if (e.Base.XmlName == AtomParserNameTable.XmlAtomEntryElement) { // the base is the Entry of the feed, let's call our parsing on the Entry AtomEntry entry = e.Base as AtomEntry; if (entry != null) { entry.Parse(e, parser); } } else { HandleExtensionElements(e, parser); } }
/// <summary> /// event on the Feed to handle extension elements during parsing /// </summary> /// <param name="e">the event arguments</param> /// <param name="parser">the parser that caused this</param> protected virtual void HandleExtensionElements(ExtensionElementEventArgs e, AtomFeedParser parser) { //Tracing.TraceMsg("Entering HandleExtensionElements on AbstractFeed"); XmlNode node = e.ExtensionElement; if (this.ExtensionFactories != null && this.ExtensionFactories.Count > 0) { //Tracing.TraceMsg("Entring default Parsing for AbstractFeed"); foreach (IExtensionElementFactory f in this.ExtensionFactories) { //Tracing.TraceMsg("Found extension Factories"); if (String.Compare(node.NamespaceURI, f.XmlNameSpace, true, CultureInfo.InvariantCulture) == 0) { if (String.Compare(node.LocalName, f.XmlName, true, CultureInfo.InvariantCulture) == 0) { e.Base.ExtensionElements.Add(f.CreateInstance(node, parser)); e.DiscardEntry = true; break; } } } } return; }