//============================================================ // PUBLIC METHODS //============================================================ #region Load(IXPathNavigable source) /// <summary> /// Initializes the syndication extension using the supplied <see cref="IXPathNavigable"/>. /// </summary> /// <param name="source">The <b>IXPathNavigable</b> used to load this <see cref="SimpleListSyndicationExtension"/>.</param> /// <returns><b>true</b> if the <see cref="SimpleListSyndicationExtension"/> was able to be initialized using the supplied <paramref name="source"/>; otherwise <b>false</b>.</returns> /// <exception cref="ArgumentNullException">The <paramref name="source"/> is a null reference (Nothing in Visual Basic).</exception> public override bool Load(IXPathNavigable source) { //------------------------------------------------------------ // Local members //------------------------------------------------------------ bool wasLoaded = false; //------------------------------------------------------------ // Validate parameter //------------------------------------------------------------ Guard.ArgumentNotNull(source, "source"); //------------------------------------------------------------ // Attempt to extract syndication extension information //------------------------------------------------------------ XPathNavigator navigator = source.CreateNavigator(); wasLoaded = this.Context.Load(navigator, this.CreateNamespaceManager(navigator)); //------------------------------------------------------------ // Raise extension loaded event //------------------------------------------------------------ SyndicationExtensionLoadedEventArgs args = new SyndicationExtensionLoadedEventArgs(source, this); this.OnExtensionLoaded(args); return(wasLoaded); }
//============================================================ // ICOMPARABLE IMPLEMENTATION //============================================================ #region CompareTo(object obj) /// <summary> /// Compares the current instance with another object of the same type. /// </summary> /// <param name="obj">An object to compare with this instance.</param> /// <returns>A 32-bit signed integer that indicates the relative order of the objects being compared.</returns> /// <exception cref="ArgumentException">The <paramref name="obj"/> is not the expected <see cref="Type"/>.</exception> public int CompareTo(object obj) { //------------------------------------------------------------ // If target is a null reference, instance is greater //------------------------------------------------------------ if (obj == null) { return(1); } //------------------------------------------------------------ // Determine comparison result using property state of objects //------------------------------------------------------------ SyndicationExtensionLoadedEventArgs value = obj as SyndicationExtensionLoadedEventArgs; if (value != null) { int result = 0; if (this.Data != null) { if (value.Data != null) { result = result | String.Compare(this.Data.OuterXml, value.Data.OuterXml, StringComparison.Ordinal); } else { result = result | 1; } } else if (value.Data != null) { result = result | -1; } if (this.Extension != null) { if (value.Extension != null) { result = result | String.Compare(this.Extension.ToString(), value.Extension.ToString(), StringComparison.Ordinal); } else { result = result | 1; } } else if (value.Extension != null) { result = result | -1; } return(result); } else { throw new ArgumentException(String.Format(null, "obj is not of type {0}, type was found to be '{1}'.", this.GetType().FullName, obj.GetType().FullName), "obj"); } }
//============================================================ // EVENT HANDLER DELEGATE METHODS //============================================================ #region OnExtensionLoaded(SyndicationExtensionLoadedEventArgs e) /// <summary> /// Raises the <see cref="SyndicationExtension.Loaded"/> event. /// </summary> /// <param name="e">A <see cref="SyndicationExtensionLoadedEventArgs"/> that contains the event data.</param> protected virtual void OnExtensionLoaded(SyndicationExtensionLoadedEventArgs e) { //------------------------------------------------------------ // Local members //------------------------------------------------------------ EventHandler <SyndicationExtensionLoadedEventArgs> handler = null; //------------------------------------------------------------ // Raise event on registered handler(s) //------------------------------------------------------------ handler = this.Loaded; if (handler != null) { handler(this, e); } }
/// <summary> /// Initializes the syndication extension using the supplied <see cref="IXPathNavigable"/>. /// </summary> /// <param name="source">The <b>IXPathNavigable</b> used to load this <see cref="SDataExtension"/>.</param> /// <returns><b>true</b> if the <see cref="SDataExtension"/> was able to be initialized using the supplied <paramref name="source"/>; otherwise <b>false</b>.</returns> /// <exception cref="ArgumentNullException">The <paramref name="source"/> is a null reference (Nothing in Visual Basic).</exception> public override bool Load(IXPathNavigable source) { //------------------------------------------------------------ // Validate parameter //------------------------------------------------------------ Guard.ArgumentNotNull(source, "source"); //------------------------------------------------------------ // Attempt to extract syndication extension information //------------------------------------------------------------ var navigator = source.CreateNavigator(); var wasLoaded = Context.Load(navigator, CreateNamespaceManager(navigator)); //------------------------------------------------------------ // Raise extension loaded event //------------------------------------------------------------ var args = new SyndicationExtensionLoadedEventArgs(source, this); OnExtensionLoaded(args); return wasLoaded; }
/// <summary> /// Raises the <see cref="SyndicationExtension.Loaded"/> event. /// </summary> /// <param name="e">A <see cref="SyndicationExtensionLoadedEventArgs"/> that contains the event data.</param> protected virtual void OnExtensionLoaded(SyndicationExtensionLoadedEventArgs e) { //------------------------------------------------------------ // Local members //------------------------------------------------------------ EventHandler<SyndicationExtensionLoadedEventArgs> handler = null; //------------------------------------------------------------ // Raise event on registered handler(s) //------------------------------------------------------------ handler = this.Loaded; if (handler != null) { handler(this, e); } }