示例#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
            //------------------------------------------------------------
            BlogMLTrackback value = obj as BlogMLTrackback;

            if (value != null)
            {
                int result = Uri.Compare(this.Url, value.Url, UriComponents.AbsoluteUri, UriFormat.SafeUnescaped, StringComparison.OrdinalIgnoreCase);

                result = result | BlogMLUtility.CompareCommonObjects(this, value);

                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");
            }
        }
示例#2
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);
            }
            BlogMLTrackback value = obj as BlogMLTrackback;

            if (value != null)
            {
                int result = Uri.Compare(this.Url, value.Url, UriComponents.AbsoluteUri, UriFormat.SafeUnescaped, StringComparison.OrdinalIgnoreCase);

                result = result | BlogMLUtility.CompareCommonObjects(this, value);

                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");
            }
        }
示例#3
0
        /// <summary>
        /// Modifies the <see cref="BlogMLPost"/> collection entities to match the supplied <see cref="XPathNavigator"/> data source.
        /// </summary>
        /// <param name="post">The <see cref="BlogMLPost"/> to be filled.</param>
        /// <param name="source">The <see cref="XPathNavigator"/> to extract information from.</param>
        /// <param name="manager">The <see cref="XmlNamespaceManager"/> used to resolve XML namespace prefixes.</param>
        /// <param name="settings">The <see cref="SyndicationResourceLoadSettings"/> used to configure the load operation.</param>
        /// <remarks>
        ///     This method expects the supplied <paramref name="source"/> to be positioned on the XML element that represents a <see cref="BlogMLPost"/>.
        /// </remarks>
        /// <exception cref="ArgumentNullException">The <paramref name="post"/> is a null reference (Nothing in Visual Basic).</exception>
        /// <exception cref="ArgumentNullException">The <paramref name="source"/> is a null reference (Nothing in Visual Basic).</exception>
        /// <exception cref="ArgumentNullException">The <paramref name="manager"/> is a null reference (Nothing in Visual Basic).</exception>
        /// <exception cref="ArgumentNullException">The <paramref name="settings"/> is a null reference (Nothing in Visual Basic).</exception>
        private static bool FillPostCollections(BlogMLPost post, XPathNavigator source, XmlNamespaceManager manager, SyndicationResourceLoadSettings settings)
        {
            //------------------------------------------------------------
            //	Local members
            //------------------------------------------------------------
            bool wasLoaded  = false;

            //------------------------------------------------------------
            //	Validate parameters
            //------------------------------------------------------------
            Guard.ArgumentNotNull(post, "post");
            Guard.ArgumentNotNull(source, "source");
            Guard.ArgumentNotNull(manager, "manager");
            Guard.ArgumentNotNull(settings, "settings");

            //------------------------------------------------------------
            //	Attempt to extract syndication information
            //------------------------------------------------------------
            XPathNodeIterator categoriesIterator    = source.Select("blog:categories/blog:category", manager);
            XPathNodeIterator commentsIterator      = source.Select("blog:comments/blog:comment", manager);
            XPathNodeIterator trackbacksIterator    = source.Select("blog:trackbacks/blog:trackback", manager);
            XPathNodeIterator attachmentsIterator   = source.Select("blog:attachments/blog:attachment", manager);
            XPathNodeIterator authorsIterator       = source.Select("blog:authors/blog:author", manager);

            if (categoriesIterator != null && categoriesIterator.Count > 0)
            {
                while (categoriesIterator.MoveNext())
                {
                    string referenceId  = categoriesIterator.Current.GetAttribute("ref", String.Empty);
                    if (!String.IsNullOrEmpty(referenceId))
                    {
                        post.Categories.Add(referenceId);
                        wasLoaded       = true;
                    }
                }
            }

            if (commentsIterator != null && commentsIterator.Count > 0)
            {
                while (commentsIterator.MoveNext())
                {
                    BlogMLComment comment   = new BlogMLComment();
                    if (comment.Load(commentsIterator.Current, settings))
                    {
                        post.Comments.Add(comment);
                        wasLoaded           = true;
                    }
                }
            }

            if (trackbacksIterator != null && trackbacksIterator.Count > 0)
            {
                while (trackbacksIterator.MoveNext())
                {
                    BlogMLTrackback trackback   = new BlogMLTrackback();
                    if (trackback.Load(trackbacksIterator.Current, settings))
                    {
                        post.Trackbacks.Add(trackback);
                        wasLoaded               = true;
                    }
                }
            }

            if (attachmentsIterator != null && attachmentsIterator.Count > 0)
            {
                while (attachmentsIterator.MoveNext())
                {
                    BlogMLAttachment attachment = new BlogMLAttachment();
                    if (attachment.Load(attachmentsIterator.Current, settings))
                    {
                        post.Attachments.Add(attachment);
                        wasLoaded               = true;
                    }
                }
            }

            if (authorsIterator != null && authorsIterator.Count > 0)
            {
                while (authorsIterator.MoveNext())
                {
                    string referenceId  = authorsIterator.Current.GetAttribute("ref", String.Empty);
                    if (!String.IsNullOrEmpty(referenceId))
                    {
                        post.Authors.Add(referenceId);
                        wasLoaded       = true;
                    }
                }
            }

            return wasLoaded;
        }