Exemplo n.º 1
0
        //============================================================
        //	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");
            }
        }
        /// <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)
        {
            EventHandler <SyndicationExtensionLoadedEventArgs> handler = null;

            handler = this.Loaded;

            if (handler != null)
            {
                handler(this, e);
            }
        }
Exemplo n.º 3
0
        /// <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 (obj == null)
            {
                return(1);
            }
            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");
            }
        }
Exemplo n.º 4
0
        //============================================================
        //	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);
            }
        }
Exemplo n.º 5
0
        /// <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);
            }
        }
Exemplo n.º 6
0
        /// <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="MyCustomSyndicationExtension"/>.</param>
        /// <returns><b>true</b> if the <see cref="MyCustomSyndicationExtension"/> 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();
            if (navigator.HasAttributes)
            {
                string myAttribute      = navigator.GetAttribute("someAttribute", String.Empty);
                if (!String.IsNullOrEmpty(myAttribute))
                {
                    this.MyAttribute    = myAttribute;
                    wasLoaded           = true;
                }
            }

            //------------------------------------------------------------
            //	Raise extension loaded event
            //------------------------------------------------------------
            SyndicationExtensionLoadedEventArgs args    = new SyndicationExtensionLoadedEventArgs(source, this);
            this.OnExtensionLoaded(args);

            return wasLoaded;
        }